gpt4 book ai didi

mysql - 在 MySQL 中更新数据会出错

转载 作者:行者123 更新时间:2023-11-29 06:39:31 25 4
gpt4 key购买 nike

update table1 
set isDeleted = 1
where isDeleted = 0
and mId in (select id from table1 where isDeleted = 1 );

错误代码:1093。您不能在 FROM 子句中指定要更新的目标表 'table1'

最佳答案

使用连接:

UPDATE table1 t1
JOIN table1 t2 ON t1.mId = t2.id
SET t1.isDeleted = 1
WHERE t1.isDeleted = 0
AND t2.isDeleted = 1

关于mysql - 在 MySQL 中更新数据会出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22342733/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com