TheEvilMonkeyMan Posted April 21, 2010 Share Posted April 21, 2010 Hey maybe somebody can help me with this query... I have two tables - jobs and users. Each job row has 'master_id' and 'slave_id' which relate to a user_id in the users table. I'd like to get a job row containing master_id and slave_id resolved to a username by id preferably in one query. I had it working somewhat at one point except that it wouldn't return rows where slave_id was null. Thanks Link to comment https://forums.phpfreaks.com/topic/199219-join-query-help/ Share on other sites More sharing options...
Mchl Posted April 21, 2010 Share Posted April 21, 2010 SELECT j.*, m.username, s.username FROM jobs AS j LEFT JOIN users AS m ON (j.master_id = m.user_id) LEFT JOIN users AS s ON (j.slave_id = s.user_id) Link to comment https://forums.phpfreaks.com/topic/199219-join-query-help/#findComment-1045623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.