mysql - How to combine two simple sql queries -
i have following sql query(s):
//get id select id magazine name = 'web designer' select avatar person newsletter = 1 , id in ( select person_id id person_magazine magazine_id = 9 //use id previous query )
how combine them don't have run 2 queries?
i think need learn joins. following query seem want:
select p.avatar person p join person_magazine pm on pm.person_id = p.id join magazine m on pm.magazine_id = m.id p.newsletter = 1 , m.name = 'web designer'
Comments
Post a Comment