1

我有一个 sql 表,比如表格

name         age
h             1
a             2
r             3
i             4

我想删除第一行和第三行。我想要某种形式的东西,

delete from tablename where name=h,r;

这是正确的语法吗?

4

5 回答 5

10

尝试:

DELETE FROM tablename WHERE name IN ('h', 'r')
于 2013-03-12T05:21:48.073 回答
2

尝试

delete from tablename where name='h' or name='r';
于 2013-03-12T05:23:56.600 回答
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');
于 2013-03-12T05:43:11.313 回答
1

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

DELETE FROM tablename 
WHERE  name = 'h' OR name ='r'
于 2013-03-12T05:23:36.957 回答
1

您可以使用 or 运算符或在类似的条件下使用

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

或者

delete from tablename where name in ('h', 'r');
于 2013-03-12T06:49:42.253 回答