我想选择表中最后一条记录并更新其名称。
UPDATE item
SET name = (SELECT name FROM pds
WHERE id = 9)
WHERE id=(SELECT id ORDER BY id DESC LIMIT 1);
然而,当执行时所有记录的名称都会发生变化。
也尝试过:
UPDATE item
SET name = (SELECT name FROM pds
WHERE id = 9)
WHERE id=(SELECT id FROM item ORDER BY id DESC LIMIT 1);
WHERE id = (SELECT MAX(id) FROM item);
可能是这样的吗? - Dacaspex