SELECT only latest record of an ID from given rows

前端 未结 4 398
生来不讨喜
生来不讨喜 2021-01-26 01:58

I have this table shown below...How do I select only the latest data of the id based on changeno?

+----+--------------+------------+--------+
| id |  data   | ch         


        
4条回答
  •  生来不讨喜
    2021-01-26 02:24

    Not a well formed or performance optimized query but for small tasks it works fine.

    SELECT * FROM TEST WHERE changeno IN (SELECT MAX(changeno) FROM TEST GROUP BY id)

提交回复
热议问题