본문 바로가기
DB/MySQL

[MySQL] SubQuery로 정렬하여 최신 ROW 가져오기

by 사용자 원동호 2020. 3. 17.

SELECT *

FROM _TABLE_

WHERE (ID, DATE) IN (

         SELECT ID, MAX(DATE) FROM _TABLE_ GROUP BY ID)

ORDER BY DATE DESC;

SELECT *
FROM _TABLE_
WHERE (ID, DATE) IN (
         SELECT ID, MAX(DATE) FROM _TABLE_ GROUP BY ID)
ORDER BY DATE DESC;

댓글0