MySQL Query with multiple AND statements seems to be ignoring one

后端 未结 5 1508
花落未央
花落未央 2020-12-20 00:25

I\'m trying to run a query on a MySQL database, but I found that it seems to be ignoring the \'status\' item.

SELECT * FROM  `posts`  
WHERE
      `tags` LIK         


        
5条回答
  •  一个人的身影
    2020-12-20 01:17

    Maybe you should use some brackets I don't know what combinations you want but try this:

      SELECT * FROM  `posts`  
        WHERE
             ( `tags` LIKE '%gda%' 
           OR `tags` LIKE '%contests%' 
           OR `tags` LIKE '%merch%' 
          )
          AND `newsID` != '2134' 
          AND `status` > '1' 
        ORDER BY  `postDate` DESC  LIMIT 5
    

提交回复
热议问题