ShoeLace1291 Posted October 24, 2011 Share Posted October 24, 2011 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 More sharing options...
ManiacDan Posted October 24, 2011 Share Posted October 24, 2011 What have you tried so far? MySQL's IF/THEN construct is very robust. Link to comment https://forums.phpfreaks.com/topic/249701-how-should-i-write-this-query/#findComment-1281759 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.