php - Joining Three Tables -



php - Joining Three Tables -

i'm trying take info 3 different tables , output using few queries , little php code possible.

listed below tables have , columns in each (only listing relevant columns).

exp_members (a) columns: member_id, group_id

exp_brandrelations (b) columns: member_id, brand_id

exp_du_mktgmats (c) columns: du_id, brand_id, date

i want loop through members belong group_id='5' (from a), determine brands assigned each fellow member (from b), , list of du_ids (from c) correspond each member, have been inserted in lastly 24 hours.

so far, can list of members in grouping 5: select member_id, brand_id exp_brandrelations where member_id in (select member_id exp_members group_id = 5)

and can list of du_ids lastly 24 hours: select du_id exp_du_mktgmats where date >= date_sub(now(), interval 1 day)

but i'm not sure how best tie together.

this should it!

select m.member_id, b.brand_id, d.du_id exp_members m, exp_brandrelations b, exp_du_mktgmats d m.group_id = '5' , m.member_id = b.member_id , b.brand_id = d.brand_id , d.date >= date_sub(now(), interval 1 day)

php mysql join

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -