按列对删除表中存在的行
我有一个表,我需要按两列删除行,例如
+------+------+--------+
| col1 | col2 | other |
+------+------+--------+
| 12 | 2 | test |
+------+------+--------+
| 14 | 2 | test1 |
+------+------+--------+
| 12 | 3 | test2 |
+------+------+--------+
| 13 | 3 | test3 |
+------+------+--------+
| 15 | 4 | test4 |
+------+------+--------+
,我想删除 (col1,col2) 对等于 (12,2),(13,3),(14,2 中任何值的行)
我可以通过纯 SQL 来做到这一点吗?
I have a table and I need to delete rows by two columns, for example
+------+------+--------+
| col1 | col2 | other |
+------+------+--------+
| 12 | 2 | test |
+------+------+--------+
| 14 | 2 | test1 |
+------+------+--------+
| 12 | 3 | test2 |
+------+------+--------+
| 13 | 3 | test3 |
+------+------+--------+
| 15 | 4 | test4 |
+------+------+--------+
and I want to delete rows that have (col1,col2) pair equal any values in (12,2),(13,3),(14,2)
Can I do this by pure SQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有很多值,请用它们填充表并执行以下操作:
If you have a lot of values, populate a table with them and do:
尝试以下sql:
Try the following sql: