Ell20 Posted August 5, 2008 Share Posted August 5, 2008 Hi, I have a query at the moment which works fine: $query = "SELECT colour, type, type_2, player_id FROM dom_bogota"; However i would like to also get username from user_info table, I have tried using INNER JOIN: SELECT colour, type , type_2, player_id, username FROM dom_bogota INNER JOIN user_info ON dom_bogota.player_id = user_info.id However this only gives the results where username actually equals something. Is there any way I can do the same thing but receive all results regardless of whether username equals something or not? Thanks for any help! Quote Link to comment https://forums.phpfreaks.com/topic/118329-solved-quick-question/ Share on other sites More sharing options...
DeanWhitehouse Posted August 5, 2008 Share Posted August 5, 2008 u could have a seperate query Quote Link to comment https://forums.phpfreaks.com/topic/118329-solved-quick-question/#findComment-608955 Share on other sites More sharing options...
Ell20 Posted August 5, 2008 Author Share Posted August 5, 2008 Could but that isnt really an option for me in this case, thanks for the suggestion though. Quote Link to comment https://forums.phpfreaks.com/topic/118329-solved-quick-question/#findComment-608956 Share on other sites More sharing options...
DarkWater Posted August 5, 2008 Share Posted August 5, 2008 Try a LEFT JOIN. Quote Link to comment https://forums.phpfreaks.com/topic/118329-solved-quick-question/#findComment-608959 Share on other sites More sharing options...
DjMikeWatt Posted August 5, 2008 Share Posted August 5, 2008 I'm not an expert, and I'm sure someone will correct me if I'm wrong here... but why can't you just use: $query = " SELECT colour, type, type_2, player_id, username FROM dom_bogota, user_info"; Quote Link to comment https://forums.phpfreaks.com/topic/118329-solved-quick-question/#findComment-608974 Share on other sites More sharing options...
Ell20 Posted August 5, 2008 Author Share Posted August 5, 2008 Cheers DarkWater, left join worked a treat! Quote Link to comment https://forums.phpfreaks.com/topic/118329-solved-quick-question/#findComment-608977 Share on other sites More sharing options...
DarkWater Posted August 5, 2008 Share Posted August 5, 2008 No problem. Quote Link to comment https://forums.phpfreaks.com/topic/118329-solved-quick-question/#findComment-608979 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.