1
最快的方式是更新nick ='a'(在一个查询中)最大id值的记录?昵称='a'的id值最大的更新记录
我的表看起来像这样:
+------+--------+----+
| nick | post | id |
+------+--------+----+
| a | tehe | 1 |
| a | tehe 2 | 2 |
| a | tehe 3 | 3 |
| b | omg | 4 |
| b | omg 2 | 5 |
| a | tehe 4 | 6 |
| b | omg 3 | 7 |
+------+--------+----+
我想:
update (select * from posts where nick='a' order by id limit 1) as last_id set post='tehe 4 updated';
但更新的目标表last_id不可更新 现在我知道它不应该工作。
update posts set post = 'tehe 4? updated' where id = (select id from posts where nick='a' order by id desc limit 1);
但在FROM子句