dhimok Posted June 24, 2007 Share Posted June 24, 2007 Hi everyone. I want to select from a table where id = querystring and status = 1 and amount is either greater then 0 or like 'unlimited' I tried to use this syntax $result = dbQuery("SELECT * FROM tbl WHERE category_id = '".$cat."' AND status = '1' AND amount > 0 OR amount LIKE '%unlimited%' ORDER BY sort_order ASC"); If i use LIKE '%unlimited%' i get the results repeating themselves. So its not working. Any help on how to get all params Thanks Quote Link to comment https://forums.phpfreaks.com/topic/56979-solved-mysql-syntax/ Share on other sites More sharing options...
btherl Posted June 25, 2007 Share Posted June 25, 2007 When you mix AND and OR, you should use brackets to make it clear what you want. Eg WHERE category_id = '".$cat."' AND status = '1' AND ( amount > 0 OR amount LIKE '%unlimited%' ) Is amount a text string that can also hold numbers? Quote Link to comment https://forums.phpfreaks.com/topic/56979-solved-mysql-syntax/#findComment-281657 Share on other sites More sharing options...
dhimok Posted June 25, 2007 Author Share Posted June 25, 2007 Thanks, I think it works now Quote Link to comment https://forums.phpfreaks.com/topic/56979-solved-mysql-syntax/#findComment-281664 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.