下面的代码很好但是......
如何在同一语句中使用带MAX()函数的Update?
类似于:UPDATE Msg SET myTime = NOW()WHERE user ='username'AND myTime = max(myTimp)
SELECT @myId:=(SELECT id FROM Msg
WHERE myTime=(SELECT MAX(myTime) FROM Msg
WHERE user='username'));
UPDATE Msq SET myTime=NOW()
WHERE id=@myId;
答案 0 :(得分:8)
UPDATE Msg
SET myTime=NOW()
WHERE user='username'
ORDER BY myTime DESC
LIMIT 1