MySQL:DELETE FROM 包含子查询中的信息
我有一个表delete_requests,其中存储用户表条目的删除请求的ID。是否可以以delete_requests中的信息为条件从用户中删除?
我的问题是,结果集通常不限于一行,而是返回几行。
DELETE FROM users WHERE id=(SELECT id FROM delete_requests)
所以 MySQL 抱怨:
#1242 - Subquery returns more than 1 row
可以在一条语句中完成此操作,而不将逻辑放入正在执行的应用程序中吗?
I have a table delete_requests where I store the id's for delete requests for the entries of my users table. Is it possible to delete from users with the information from delete_requests as a condition?
My problem is, that the result set will usually not be limited to one row but return several.
DELETE FROM users WHERE id=(SELECT id FROM delete_requests)
So MySQL complains:
#1242 - Subquery returns more than 1 row
Can this be done in one statement without putting the logic into the executing application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 IN 子句
Use the IN clause
您可以使用 in 子句。
You can use the in clause.