SQL 从sql表中删除多行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15353874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:12:21  来源:igfitidea点击:

deleting multiple rows from sql table

sqlsql-server-2008sql-delete

提问by user1915108

I got a sql table, say of the form

我有一个 sql 表,说的形式

name         age
h             1
a             2
r             3
i             4

I want to delete the 1st row and 3rd row. I want something of the form,

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

delete from tablename where name=h,r;

is this the correct syntax?

这是正确的语法吗?

回答by TechDo

Try:

尝试:

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

回答by Maadh

Try

尝试

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

回答by Rahul

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');

回答by subinpanicker

You may use or operator or in condition like

您可以使用或运营商或在条件像

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

Or

或者

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

回答by John Woo

You need to use conditional operator such as `OR,

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

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