SELECT projects.*, project_members.user_id AS leader
LEFT JOIN project_members ON project_members.project_id = projects.id
WHERE projects.id = '3'
AND project_members.leader = 1;
I need this to join only one row from the project_members table, all other members will have a leader = 0 value. Is there a way to limit joins like this?
exactly like you did, except using an INNER JOIN