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
)
网友评论