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