查询删除id不是多个值的位置?

时间:2012-11-07 06:19:36

标签: sql

如何进行查询以删除id不是多个值的列?

我试过

DELETE FROM `Player` WHERE `Player`.`Squad` != 3,
4,
8,
9,
10,
11,
21, 
31,
36,
43,
64,
65,
66,
71,
74,
103,
105,
154,
171,
190;

由于

5 个答案:

答案 0 :(得分:2)

使用NOT IN,如下所示:

 DELETE FROM Player WHERE Player.Squad NOT IN ( 3, 4, 8,9,10,11,21, 31,36,43,
                                            64,65,66,71,74,103,105,154,171,190);

答案 1 :(得分:2)

你可以尝试

Delete from player where player.squad not in (3,4,8,9,10,...)

答案 2 :(得分:2)

DELETE FROM Player WHERE Squad NOT IN(3,4,8,9 ..........); http://dev.mysql.com/doc/refman/5.5/en//example-foreign-keys.html请参阅dz链接了解更多信息

答案 3 :(得分:1)

您可以使用 NOT IN

DELETE FROM `Player` WHERE `Player`.`Squad` not in (3,4,8,...)

答案 4 :(得分:0)

使用NOT IN sql不区分大小写我们可以使用small或caps没问题。

DELETE FROM Player WHERE Squad NOT IN ( 3, 4, 8,9,10,11,21, 31,36,43,
                                        64,65,66,71,74,103,105,154,171,190);