【问题标题】:Update Data In MySQL Gives Error在 MySQL 中更新数据会出错
【发布时间】:2014-03-12 05:27:42
【问题描述】:
update table1 
set isDeleted = 1 
where isDeleted = 0 
and mId in (select id from table1 where isDeleted = 1 );

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

【问题讨论】:

标签: mysql


【解决方案1】:

使用连接:

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

【讨论】:

    猜你喜欢
    • 2012-10-04
    • 2019-09-26
    • 2012-08-16
    • 2023-03-22
    • 2020-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多