holowugz Posted April 3, 2006 Share Posted April 3, 2006 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? Quote Link to comment Share on other sites More sharing options...
Guest footballkid4 Posted April 3, 2006 Share Posted April 3, 2006 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--] Quote Link to comment Share on other sites More sharing options...
Desdinova Posted April 3, 2006 Share Posted April 3, 2006 try changingclass = 2 OR class = 1to (class = 2 OR class = 1) Quote Link to comment Share on other sites More sharing options...
holowugz Posted April 3, 2006 Author Share Posted April 3, 2006 OH i did not know that at all, i dont know what i would have done, thankyou to the both of you ! :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.