我正在使用 MySql 中的一个表执行“where contains”查询。它与 SELECT * 一起工作正常,但当我尝试执行 DELETE 而不是 SELECT * 时失败。
如何使用删除执行相同的查询?非常感谢!
select * from MyTable t1 where exists (
select * from MyTable t2 where t1.user_id = t2.user_id
and t1.object_id <> t2.object_id and t2.role = "ADMIN")
and role = "ORG_MANAGER"
and object_type = "type_b";
最佳答案
delete from MyTable t1
where user_id in (
select user_id
from MyTable t1
where exists (
select * from MyTable t2
where t1.user_id = t2.user_id
and t1.object_id <> t2.object_id
and t2.role = "ADMIN")
and role = "ORG_MANAGER"
and object_type = "type_b";
)
关于mysql - MySQL 中使用 WHERE EXISTS 进行删除查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38754497/