我有一个表有一个列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
答案 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