1
は、一番大きいid値のレコードを更新する最も速い方法は何ですか?最大のid値を持つレコードを更新するにはnick = 'a'
私のテーブルには、次のようになります。
update (select * from posts where nick='a' order by id limit 1) as last_id set post='tehe 4 updated';
のが、UPDATEのターゲットテーブルlast_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 posts set post = 'tehe 4? updated' where id = (select id from posts where nick='a' order by id desc limit 1);
しかし、あなたは句