There are so many ways to solve this, but I'm used to doing it this way. An additional subquery is needed to separately calculate the last cDate for each ID .
SELECT a.*, c.* FROM theme a INNER JOIN notice_theme b ON a.ID = b.id_theme INNER JOIN notice c ON b.id_notice = c.ID INNER JOIN ( SELECT a.id_theme, MAX(b.DATE_CREATE) max_date FROM notice_theme a INNER JOIN notice b ON a.ID_Notice = b.ID GROUP BY a.id_theme ) d ON b.id_theme = d.id_theme AND c.DATE_CREATE = d.max_date
John woo
source share