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. Quote Link to comment 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] Quote Link to comment 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!!!! Quote Link to comment 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.