如何在SQL中删除多个值? [英] How to delete several values in SQL?

查看:159
本文介绍了如何在SQL中删除多个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用如下语句删除一组行:

I know how to delete a set of rows with a statements like these:

DELETE FROM my_table WHERE id=23 AND year=2012 AND value=16
DELETE FROM my_table WHERE id=17 AND year=2012 AND value=16
DELETE FROM my_table WHERE id=64 AND year=2012 AND value=16

但是我想将上述三个语句组合成一个ID为23、17或64的DELETE.

But I would like to combine the above three statements into a single DELETE where id is either 23, 17, or 64.

在Oracle SQL中执行此操作的语法是什么?

What is the syntax for doing this in Oracle SQL?

推荐答案

您可以使用SQL IN关键字.例如:

You can use the SQL IN keyword. For example:

DELETE FROM my_table WHERE id IN (23, 17, 64) AND year=2012 AND value=16

注意: Oracle列表中的项数上限为1,000.

Note: Oracle has a limit of 1,000 items in a list.

这篇关于如何在SQL中删除多个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆