Jump to content

How Should I Write This Query


ShoeLace1291

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

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.