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? Link to comment https://forums.phpfreaks.com/topic/57001-solved-cant-you-use-and-and-or-in-mysql-querys/ 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 Link to comment https://forums.phpfreaks.com/topic/57001-solved-cant-you-use-and-and-or-in-mysql-querys/#findComment-281570 Share on other sites More sharing options...
JJohnsenDK Posted June 24, 2007 Author Share Posted June 24, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/57001-solved-cant-you-use-and-and-or-in-mysql-querys/#findComment-281598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.