gpt4 book ai didi

mysql - 错误代码 : 1093. 表 'site_html' 被指定了两次,既作为 'UPDATE' 的目标又作为数据的单独源

转载 作者:行者123 更新时间:2023-11-29 05:12:14 27 4
gpt4 key购买 nike

我想用相应的 id 更新表的“状态”列,但它导致我出现错误代码 1093。下面是我的 SQL 查询

Update site_html Set status='Update Found' 
Where id = (
select id
from site_html
where link='http://www.example.com');

我该如何纠正这个错误?我是 SQL 的新手。

最佳答案

在 MySQL 中,您不能直接修改在 SELECT 部分中使用的同一个表名。所以你可以通过表别名来完成。

update site_html AS s, (select id  from site_html where link='http://www.example.com') AS t
set status='Update Found'
where s.id = t.id;

关于mysql - 错误代码 : 1093. 表 'site_html' 被指定了两次,既作为 'UPDATE' 的目标又作为数据的单独源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37781289/

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