mysql 同表 B字段值赋值给A字段 update 语句

时间:2022-10-28 08:55:39

mysql 表table_a B字段值赋值给A字段 update 语句

-- 同一个表
UPDATE table_a SET A=(SELECT B FROM (SELECT * FROM table_a) b WHERE b.id = table_a.id) -- 两个表 UPDATE table_a SET A = (SELECT B FROM table_b WHERE table_b.ID= table_a.ID) -- UPDATE message SET image=(SELECT istatus FROM (SELECT * FROM message) b WHERE b.id = message.id)