是否有更清晰的语法为WHERE id!= 1 AND id!= 2 AND id!= 7

时间:2009-07-29 20:30:15

标签: mysql

在MySQL中有更简洁的方法来执行此查询吗?

SELECT * FROM table WHERE id != 1 AND id != 2 AND id != 7

像:

SELECT * FROM table WHERE id != (1,2,7)

1 个答案:

答案 0 :(得分:23)

SELECT * FROM table WHERE id NOT IN (1,2,7)