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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.