如果我运行查询:
SELECT *
FROM mag2
WHERE environments_env_id LIKE '%test%'
OR environments_env_id LIKE '%test%'
OR environments_env_type LIKE '%test%'
OR environments_host_label LIKE '%test%'
OR environments_host_type LIKE '%test%'
OR environments_local_id LIKE '%test%'
OR samples_date_added LIKE '%test%'
OR samples_description LIKE '%test%'
OR samples_exec_arguments LIKE '%test%'
OR samples_label LIKE '%test%'
OR samples_owner LIKE '%test%'
OR samples_sample_id LIKE '%test%'
OR samples_sample_type LIKE '%test%'
OR samples_source LIKE '%test%'
OR task_state_state LIKE '%test%'
OR task_state_state_id LIKE '%test%'
OR tasks_env_id LIKE '%test%'
OR tasks_env_return_code LIKE '%test%'
OR tasks_env_runtime LIKE '%test%'
OR tasks_env_start LIKE '%test%'
OR tasks_exec_arguments LIKE '%test%'
OR tasks_global_risk_score LIKE '%test%'
OR tasks_owner_risk_score LIKE '%test%'
OR tasks_sample_id LIKE '%test%'
OR tasks_state_id LIKE '%test%'
OR tasks_task_id LIKE '%test%'
OR tasks_task_start LIKE '%test%'
OR event LIKE '%test%'
我得到 249 的结果。我想使用 NOT IN 和 tasks_task_id 从查询中消除 100 个结果,task_task_id 是数据库上的唯一索引并且没有任何重复项。我的 AND NOT IN 声明如下:
SELECT *
FROM mag2
WHERE environments_env_id LIKE '%test%'
OR environments_env_id LIKE '%test%'
OR environments_env_type LIKE '%test%'
OR environments_host_label LIKE '%test%'
OR environments_host_type LIKE '%test%'
OR environments_local_id LIKE '%test%'
OR samples_date_added LIKE '%test%'
OR samples_description LIKE '%test%'
OR samples_exec_arguments LIKE '%test%'
OR samples_label LIKE '%test%'
OR samples_owner LIKE '%test%'
OR samples_sample_id LIKE '%test%'
OR samples_sample_type LIKE '%test%'
OR samples_source LIKE '%test%'
OR task_state_state LIKE '%test%'
OR task_state_state_id LIKE '%test%'
OR tasks_env_id LIKE '%test%'
OR tasks_env_return_code LIKE '%test%'
OR tasks_env_runtime LIKE '%test%'
OR tasks_env_start LIKE '%test%'
OR tasks_exec_arguments LIKE '%test%'
OR tasks_global_risk_score LIKE '%test%'
OR tasks_owner_risk_score LIKE '%test%'
OR tasks_sample_id LIKE '%test%'
OR tasks_state_id LIKE '%test%'
OR tasks_task_id LIKE '%test%'
OR tasks_task_start LIKE '%test%'
OR event LIKE '%test%'
AND `tasks_task_id` NOT IN ( '1762', '1763', '1764', '1765',
'1766', '1779', '1787', '1836',
'1837', '1838', '1839', '1840',
'1841', '1850', '1852', '1856',
'1893', '1914', '1927', '1946',
'1955', '1957', '1969', '1985',
'1986', '2016', '2026', '2038',
'2063', '2098', '2110', '2133',
'2136', '2148', '5056', '5066',
'5068', '5070', '5084', '5106',
'5120', '5132', '5136', '5146',
'5150', '5152', '539', '546',
'547', '548', '549', '550',
'551', '557', '563', '565',
'587', '589', '590', '594',
'602', '603', '621', '622',
'623', '624', '625', '626',
'627', '637', '640', '642',
'643', '645', '646', '648',
'650', '651', '656', '657',
'658', '662', '663', '664',
'665', '671', '672', '675',
'676', '677', '687', '688',
'691', '693', '695', '699',
'701', '702', '756', '762' )
它产生的结果是 150 而不是 149,我不知道为什么。我也尝试了 AND != 并得到了相同的结果。有人可以解释为什么吗?