gonny Posted October 22, 2007 Share Posted October 22, 2007 Hi! $query = $DB->query( "SELECT id, id_cat, title, field1, image FROM articles WHERE id_cat=1 OR id_cat=2 OR id_cat=3 OR id_cat=4 AND field1=1 ORDER BY `id` DESC LIMIT 1"); This must show articles from category 1 or 2 or 3 or 4 where field1 is 1 order by id and limit 1. The problem is to field1 this query show articles where field1 has value 0 (field1=0). How can solve this or where is the problem in this query? Link to comment https://forums.phpfreaks.com/topic/74363-solved-mysql-problem/ Share on other sites More sharing options...
fenway Posted October 22, 2007 Share Posted October 22, 2007 You need to put parens around the group of OR conditions. Link to comment https://forums.phpfreaks.com/topic/74363-solved-mysql-problem/#findComment-375709 Share on other sites More sharing options...
gonny Posted October 22, 2007 Author Share Posted October 22, 2007 for example? show me how... Link to comment https://forums.phpfreaks.com/topic/74363-solved-mysql-problem/#findComment-375716 Share on other sites More sharing options...
roopurt18 Posted October 22, 2007 Share Posted October 22, 2007 WHERE (id_cat=1 OR id_cat=2 OR id_cat=3 OR id_cat=4) AND field1=1 Link to comment https://forums.phpfreaks.com/topic/74363-solved-mysql-problem/#findComment-375719 Share on other sites More sharing options...
gonny Posted October 22, 2007 Author Share Posted October 22, 2007 Work now! Thnx a lot guys Link to comment https://forums.phpfreaks.com/topic/74363-solved-mysql-problem/#findComment-375729 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.