Get MAX value in mysql query

前端 未结 3 1592
无人共我
无人共我 2021-01-05 05:38

I have a table

       id     mid    userid    remarks
       1       2       8          7 
       2       2       8          6
       3       2       8               


        
3条回答
  •  囚心锁ツ
    2021-01-05 06:06

    Try this:

        SELECT MAX(id),mid,userid,remarks 
        FROM sample WHERE id NOT IN  (
        SELECT MAX(id) FROM sample
        )
        GROUP BY mid,userid,remarks 
    

    EDIT

    See if this works

    SQL FIDDLE DEMO

提交回复
热议问题