美文网首页
[Err] 1093 - You can't specify t

[Err] 1093 - You can't specify t

作者: 一位先生_ | 来源:发表于2020-06-01 11:34 被阅读0次

1: 执行下方的sql语句 报错
UPDATE user SET cellNumber="13764031314",showName="13764031314",userName="13764031314"
WHERE userId IN(
SELECT userId FROM user WHERE cellNumber="13764031398"
);
2:先修改如下
/**
意思就是变个方向,在select外边套一层,让数据库认为你不是查同一表的数据作为同一表的更新数据:
*/
UPDATE user SET cellNumber="13764031315",showName="13764031315",userName="13764031315"
WHERE userId IN(
SELECT u.userId FROM
(
SELECT * FROM user WHERE cellNumber="13764031398"
) u
) ;

完美解决!

实例:
update armarium_gc_device set armarium_device_e = 2000
where armarium_device_id in (
select gc.armarium_device_id from (select * from armarium_gc_device where armarium_device_e < 100) gc
)

相关文章

网友评论

      本文标题:[Err] 1093 - You can't specify t

      本文链接:https://www.haomeiwen.com/subject/gfmjzhtx.html