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子句