Jump to content

SELECT statement


Siggles

Recommended Posts

I have a select statement....

 

"SELECT fixtures.opponent, fixtures.resultus, fixtures.resultthem, predictions.resultus1, predictions.resultthem1 FROM predictions Inner Join fixtures ON fixtures.id = predictions.id AND predictions.username = '$session->username'"

 

The fixtures table holds the details of the individual football fixtures and the result of the fixture.

The predictions table holds the data of individual preidcitons made by users.

There is a third table, users.

Fixtures and predictions tables are referenced by the id column which is in each table. If a prediction is made, it will be given an id that will link it to the fixture id.

 

If I use the above select statement using = for the ON bit it works fine and returns only fixtures where the user has made a prediction. I f I exchange that for <> it shows all the other fixtures where he has not made a prediction but puts the prediction from the other game into all rows.

 

        Opponent    Score    Your prediction

Eg =  West Ham    1 -0      2-0

 

Eg <>  Opponent  Score    Your Prediction

          Chelsea    2-0      2-0 *

          Arsenal    3-1      2-0 *

 

*Basically takes this from the other result.

 

Can you help? Hope that made sense.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/87225-select-statement/
Share on other sites

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.