从sql表中删除多行

时间:2013-03-12 05:21:00

标签: sql sql-server-2008 sql-delete

我有一个sql表,比如表格

name         age
h             1
a             2
r             3
i             4

我想删除第1行和第3行。 我想要一些形式,

delete from tablename where name=h,r;

这是正确的语法吗?

5 个答案:

答案 0 :(得分:10)

尝试:

DELETE FROM tablename WHERE name IN ('h', 'r')

答案 1 :(得分:2)

尝试

delete from tablename where name='h' or name='r';

答案 2 :(得分:2)

You may use or operator or in condition like
delete from tablename where name='h' or name='r';

delete from tablename where name in ('h', 'r');

答案 3 :(得分:1)

您需要使用条件运算符,例如`OR,

DELETE FROM tablename 
WHERE  name = 'h' OR name ='r'

答案 4 :(得分:1)

您可以使用或运营或在

之类的条件下使用
delete from tablename where name='h' or name='r';

或者

delete from tablename where name in ('h', 'r');