开发者

Update with MAX() in MySql

The code bellow works great but...

How can I use Update with a MAX() function in the same statement?

Something like: 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开发者_如何学Python user='username'));

UPDATE Msq SET myTime=NOW() 
WHERE id=@myId;


  UPDATE Msg
     SET myTime=NOW()
   WHERE user='username'
ORDER BY myTime DESC
   LIMIT 1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜