MySQL:不喜欢

我有这些文字在我的分贝,

categories_posts categories_news posts_add news_add 

而我不想selectcategories的行,我使用这样的查询,

 SELECT * FROM developer_configurations_cms WHERE developer_configurations_cms.cat_id = '1' AND developer_configurations_cms.cfg_variables LIKE '%parent_id=2%' AND developer_configurations_cms.cfg_name_unique NOT LIKE '%categories%' 

但它在输出中返回这两个以及…

 categories_posts categories_news 

如何在我的查询中忽略它们?

谢谢。

categories_postscategories_news以子string“categories_”开头,那么检查developer_configurations_cms.cfg_name_unique是以“categories”开头而不是检查是否包含给定子string就足够了。 将所有这些转换成查询:

 SELECT * FROM developer_configurations_cms WHERE developer_configurations_cms.cat_id = '1' AND developer_configurations_cms.cfg_variables LIKE '%parent_id=2%' AND developer_configurations_cms.cfg_name_unique NOT LIKE 'categories%' 

我不知道为什么

 cfg_name_unique NOT LIKE '%categories%' 

仍然返回这两个值,但可能会明确排除它们:

 SELECT * FROM developer_configurations_cms WHERE developer_configurations_cms.cat_id = '1' AND developer_configurations_cms.cfg_variables LIKE '%parent_id=2%' AND developer_configurations_cms.cfg_name_unique NOT LIKE '%categories%' AND developer_configurations_cms.cfg_name_unique NOT IN ('categories_posts', 'categories_news')