update statement using nested query

后端 未结 6 1791
梦谈多话
梦谈多话 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条回答
  •  隐瞒了意图╮
    2020-12-14 07:23

    you can simply write a nested query like this

    
        Update  mytable a 
        set 
        a.lastLogDate = (select max(logDate) from mytable b
        where a.id=b.id)
        Where...;
    

提交回复
热议问题