본문 바로가기
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;

반응형

댓글