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 Quote 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) Quote Link to comment https://forums.phpfreaks.com/topic/199219-join-query-help/#findComment-1045623 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.