update statement using nested query

后端 未结 6 1808
梦谈多话
梦谈多话 2020-12-14 06:33

I have a table:

mytable:
    id
    userID
    logDate
    lastLogDate

For every row in that table, I want to update the \'lastLogDate\' co

6条回答
  •  旧时难觅i
    2020-12-14 07:20

    Following update statement should do what you are looking for

    update mytable mt set  lastLogDate  = (select max(logDate) from  mytable where userID = mt.userID)
    

提交回复
热议问题