bateati Posted October 11, 2011 Share Posted October 11, 2011 I'm trying to search the 'ad' column where 'ad' = 1 or 3 I'm having problems doing this. Here is what I currently have, but it is not bringing back 'ad' where ='1' (for obvious reasons) $query = "SELECT * FROM users WHERE ad='3' AND state='$state1'"; Here is what I thought would work, but it displays every listing in my database when I do it this way. $query = "SELECT * FROM users WHERE ad='3' OR ad='1' AND state='$state1'"; Thank you in advance for your answers, google is not being so kind to me right now. Quote Link to comment https://forums.phpfreaks.com/topic/248870-mysql-search-where-question-should-be-easy-answer/ Share on other sites More sharing options...
MasterACE14 Posted October 11, 2011 Share Posted October 11, 2011 both queries are fine. If you want to 'limit' the results add "LIMIT 25" or whatever number to the end of the query. Quote Link to comment https://forums.phpfreaks.com/topic/248870-mysql-search-where-question-should-be-easy-answer/#findComment-1278030 Share on other sites More sharing options...
BigTime Posted October 11, 2011 Share Posted October 11, 2011 Hi bateati try WHERE (ad='1' OR ad='3') Quote Link to comment https://forums.phpfreaks.com/topic/248870-mysql-search-where-question-should-be-easy-answer/#findComment-1278032 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.