Jump to content

[SOLVED] Cant you use AND and OR in mysql querys?


JJohnsenDK

Recommended Posts

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?

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.