PDA

View Full Version : Mysql query not pulling correct data


Jacobb123
12-10-2008, 07:49 PM
I have the following query but it seems to pull all data in the table instead of using the actual query I have setup. Can anyone see any problems with it?




SELECT * FROM job_posting where body LIKE '%$term%' or heading LIKE '%$term%' and active = '1' and state ='{$_POST['state']}' order by expires_on ASC




The problem seems to be in the OR statement that I have because if I pull it out it work fine. any suggestions?

Fumigator
12-10-2008, 09:02 PM
You need to set the precedence for all those ORs and ANDs.

Do you mean:

WHERE (A or B) and C and D


Or


WHERE A or (B and C and D)


?