ViperSBT Posted May 9, 2006 Share Posted May 9, 2006 OK, I am trying to do the following query:[code]SELECT d.dnumber AS RUN, SUM(p.points) AS Points FROM dogs d JOIN points p ON p.dog = d.dnumber GROUP BY d.dnumber[/code]This returns a list of RUNs with associated Points, but it only recognizes RUNs that exist in both the dogs and points tables. I need all dogs in the dogs table regardless is they exist in the points table. If they don't exist in the points table I am expecting a null or 0 for the Points result for that RUN. Link to comment https://forums.phpfreaks.com/topic/9390-another-query-quandry/ Share on other sites More sharing options...
Barand Posted May 9, 2006 Share Posted May 9, 2006 Use a LEFT JOIN[code]SELECT d.dnumber AS RUN, SUM(p.points) AS Points FROM dogs d LEFT JOIN points p ON p.dog = d.dnumber GROUP BY d.dnumber[/code] Link to comment https://forums.phpfreaks.com/topic/9390-another-query-quandry/#findComment-34779 Share on other sites More sharing options...
ViperSBT Posted May 10, 2006 Author Share Posted May 10, 2006 Dude, I couldn't feel more stupid!Thank you, once again PHP Freaks saves the day!!!! Link to comment https://forums.phpfreaks.com/topic/9390-another-query-quandry/#findComment-34799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.