是否存在等同于
的查询WHERE some_field IN (1, 2, !3, !4)
意思
WHERE some_field = 1 AND some_field = 2 AND some_field != 3 AND some_field != 4
?
答案 0 :(得分:-2)
您应该具有以下where
条件之一,因为两者并不合理: -
WHERE some_field IN (1, 2)
或
WHERE some_field NOT IN (3, 4)
答案 1 :(得分:-2)
这很大程度上取决于背景。
Where some_field IN (1, 2)
已经不会返回some_field等于3或4的记录。
可能的情况是你有一个表有许多版本的some_field与相同的ID相关联,并且你只想返回那些有1和2个some_fields的表,但是如果他们在表中也有3或4,那么你想要排除它们。然后你会想做类似的事情:
Select * from table
WHERE some_field = 1
AND some_ID in (select some_ID from table
where some_field = 2)
AND some_ID Not IN (select some_ID from table
where some_field IN (3, 4))
这将从some_field为1和2的结果列表中排除some_field值为3或4的所有id