close

SELECT *  FROM table as t1
left join table2 as t2
on t1.id = t2.t1_id
where t2.time = (SELECT max(time) from table2 as t22
where t22.t1_id=t1.id);

參考資料:

http://dev.mysql.com/doc/refman/5.7/en/example-maximum-column-group.html

arrow
arrow
    文章標籤
    mysql group by
    全站熱搜

    kkkelu1008 發表在 痞客邦 留言(0) 人氣()