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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
gonny Posted October 22, 2007 Author Share Posted October 22, 2007 for example? show me how... Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
gonny Posted October 22, 2007 Author Share Posted October 22, 2007 Work now! Thnx a lot guys Quote Link to comment 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.