Jump to content

Recommended Posts

I am trying to create a query that selects results from a table called matches.  The results from this table must be based on whether or not there are results from another table called match_results.  The results from the match_results table must be based on whether or not the row has either a home_id equal to the current team id, or a visitor_id equal to the current team id.  If the current team id is equal to the home_id of the result from the match_results table, then the home_score must be greater than the visitor_score.  If the current team id is equal to the visitor_id of the result from the match_results table, then the visitor_score must be greater than the home_score. 

 

In short, I am trying to make a query that finds a team's match record(wins and losses).  If the result from the matches table doesn't have any results from the match_results table with the same match id, then it hasn't been played it.  I hope this makes sense.  Is there any way to do this in one single query?

 

 

 

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/249701-how-should-i-write-this-query/
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.