I have this sql which works fine, it lists all members even if they don't have a record in badge_req qhich is what i want it to do
SELECT m.first_name, m.last_name, r . *
FROM smdbs_members AS m
LEFT JOIN smdbs_member_badge_req AS r ON r.mem_id = m.mem_id
AND r.req_id =518
WHERE section =3
AND `left` = '0000-00-00'
ORDER BY last_name, first_name
i now want to add a field from another table, so i changed the code to
SELECT m.first_name, m.last_name, r. * , g . *
FROM smdbs_members AS m
LEFT JOIN smdbs_member_badge_req AS r ON r.mem_id = m.mem_id
LEFT JOIN smdbs_member_badge_got AS g ON g.mem_id = m.mem_id
AND badge_id =49
WHERE section =3
AND r.req_id =1
AND `left` = '0000-00-00'
ORDER BY last_name, first_name
Now it misses out those that don't have a record in the other two tables, though i still want it to show them.
How would i go about chaging the sql so that it shows all members (its shows 15 not 16 at the moment)