获取错误的数据MySQL

时间:2016-12-02 06:12:23

标签: php mysql

我有一个表有一个列test_id我需要获取不等于 t-0105,t-0120,t-044,t-063,t-064,t-068,t的数据-072 但查询获取所有数据。

select * from test_name where test_type='p' and test_id NOT IN ('t-0105,t-0120,t-044,t-063,t-064,t-068,t-072') and test_list='tt' and test_name like '%aptitude%' and published=1 order by id asc

1 个答案:

答案 0 :(得分:4)

您将单引号'视为错误。在您的查询中IN条件将所有值作为单个字符串。你应该添加它,如下所示。

select * from test_name where test_type='p' and test_id NOT IN ('t-0105','t-0120','t-044','t-063','t-064','t-068','t-072') and test_list='tt' and test_name like '%aptitude%' and published=1 order by id asc