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 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? 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 Link to comment https://forums.phpfreaks.com/topic/56979-solved-mysql-syntax/#findComment-281664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.