Jump to content

MYSQL Query Problem


holowugz

Recommended Posts

Hi,

i have been working on this for a while and it is killing me i am not too sure what to do.

[code]mysql_select_db($database_connFish, $connFish);
$query_rsCareerAwards = "SELECT * FROM career_record_data WHERE record_id = {$record_ID} AND class = 2 OR class = 1 ORDER BY date_Time ASC ";
$rsCareerAwards = mysql_query($query_rsCareerAwards, $connFish) or die(mysql_error());
$row_rsCareerAwards = mysql_fetch_assoc($rsCareerAwards);
$totalRows_rsCareerAwards = mysql_num_rows($rsCareerAwards);[/code]


It when ever i run the query if the record_id is 1 it runs fine but if i run others it brings back some of the records in which the record_id is 1 and it shouldnt.

is the query wrong or something?
Link to comment
Share on other sites

Guest footballkid4
You want to group your OR statements
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * [color=green]FROM[/color] [color=orange]career_record_data[/color] [color=green]WHERE[/color] record_id[color=orange]=[/color][color=red]'{$record_ID}'[/color] [color=blue]AND[/color] (class[color=orange]=[/color][color=red]'2'[/color] [color=blue]OR[/color] class[color=orange]=[/color][color=red]'1'[/color]) [color=green]ORDER BY[/color] date_Time ASC; [!--sql2--][/div][!--sql3--]
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.