ballouta Posted September 30, 2008 Share Posted September 30, 2008 Hello I have the table 'members' of the following headers: ID user password reseller 2 malek 123 Y 3 maher 456 N etc... and the table 'rescus' with the following headers: ID customer reseller credits 6 malek XXX 50 100 Samer XXX 6 i wanna loop and print all members ='Y' and their credits frm the second table, i wrote this query but it is not giving me a correct result: <?php $query = "SELECT members.user, rescus.customer, rescus.credits FROM rescus INNER JOIN members ON rescus.customer = members.user where members.reseller ='Y'"; ?> Please Help Thank You Link to comment https://forums.phpfreaks.com/topic/126526-inner-join-problem/ Share on other sites More sharing options...
Barand Posted September 30, 2008 Share Posted September 30, 2008 That looks as though it would give [pre] malek malek 50[/pre] Link to comment https://forums.phpfreaks.com/topic/126526-inner-join-problem/#findComment-654324 Share on other sites More sharing options...
ballouta Posted September 30, 2008 Author Share Posted September 30, 2008 yes this is what i want, do u mean the query is correct? Link to comment https://forums.phpfreaks.com/topic/126526-inner-join-problem/#findComment-654331 Share on other sites More sharing options...
Barand Posted September 30, 2008 Share Posted September 30, 2008 I haven't tried it but it looks OK. What were you getting for you to say it's incorrect? Link to comment https://forums.phpfreaks.com/topic/126526-inner-join-problem/#findComment-654336 Share on other sites More sharing options...
ballouta Posted September 30, 2008 Author Share Posted September 30, 2008 I said it's incorrect because the result is missing few rows, i got three rows while expected 7. I think I have to review the data in the second table and make sure that they are exisit. Thank you Link to comment https://forums.phpfreaks.com/topic/126526-inner-join-problem/#findComment-654337 Share on other sites More sharing options...
Barand Posted September 30, 2008 Share Posted September 30, 2008 If you are trying to list all members with "Y" even they have no record in "rescus" then you need FROM members LEFT JOIN rescus ON .... Link to comment https://forums.phpfreaks.com/topic/126526-inner-join-problem/#findComment-654340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.