C/C++教程

sql写删除语句无法运行,报 You can't specify target table 'users' for update in FROM clause 错误的解决

本文主要是介绍sql写删除语句无法运行,报 You can't specify target table 'users' for update in FROM clause 错误的解决,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

报错语句:

delete
from users
where username in (
    select username from users where enabled = 0
)

解决办法:

修改子查询,多嵌套一层

delete
from users
where username in (
    select * from (
    	select username from users where enabled = 0
    ) t
)
这篇关于sql写删除语句无法运行,报 You can't specify target table 'users' for update in FROM clause 错误的解决的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!