Jump to content

[SOLVED] GROUP BY clause restricting amount of data a query will show.


Siggles

Recommended Posts

Hi I have a query..

 

SELECT predictions.resultmfc, predictions.resultother, predictions.score, fixtures.opponent, fixtures.resultus, fixtures.resultthem, fixtures.homeaway, predictions.id, predictions.username, 
DATE_format( fixtures.dateplayed, '%M %e, %Y' ) AS newdate, predictions.predictionid, 
SUM( predictions.score ) AS Total_Score FROM fixtures 
RIGHT JOIN predictions ON predictions.id = fixtures.id 
GROUP BY predictions.username 
ORDER BY dateplayed, username

 

because I have the GROUPBY clause in there it will only display the predictions from my database for one fixture because it will only show one prediciton per user. If I remove the SUM(predictions.score) and GROUP BY sections fromt he query the page displays correctly but I cannot show users individual score for each preidction. If I change the GROUP BY clause to fixtures.opponent then it shows both fixtures but only one prediction from each.

 

Anyone know what I can do here to rememdy this?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.