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?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.