Jump to content

Archived

This topic is now archived and is closed to further replies.

holowugz

MYSQL Query Problem

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?

Share this post


Link to post
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--]

Share this post


Link to post
Share on other sites
OH i did not know that at all, i dont know what i would have done, thankyou to the both of you ! :D

Share this post


Link to post
Share on other sites

×

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.