JJohnsenDK Posted June 24, 2007 Share Posted June 24, 2007 Hey I have this: <?php $sql = mysql_query("SELECT season_ID, game_no, home_id, visitor_id, date FROM game WHERE home_id = '$team_id' OR visitor_id = '$team_id' AND season_ID = '$year'") or die(mysql_error()); ?> I have 33 ( 16 home matches and 17 away matches) matches in 2006 and 33 ( 16 home matches and 17 away matches) matches in 2005 and i ofcause want to show these matches seperatly so i only see the 33 matches from 2005 when season_ID = 2005. But if $year is equal to 2005 i also get the 16 home matches from 2006? If i then try to remove home_id = '$team_id' i get all the away matches, but only from 2005. Same the ohter way around if i remove visitor_id = '$team_id'. Its like AND and OR cant work together? Quote Link to comment Share on other sites More sharing options...
Barand Posted June 24, 2007 Share Posted June 24, 2007 if you use AND and OR, use () to make the logic clear Is it WHERE a AND (b or c) or WHERE (a AND b) or c Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted June 24, 2007 Author Share Posted June 24, 2007 thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.