Select rows from one table, join most recent row from other table with one-to-many relationship

邮差的信 提交于 2019-11-29 16:49:25
Kushan

I think this will help you:

SELECT A.id, A.col_1, A.col_2, A.datetime_col, A.col_3
FROM
    (SELECT B.id, B.col_1, B.col_2, C.datetime_col, C.col_3
    FROM tableA B LEFT OUTER JOIN tableB C ON B.id = C.id
    ORDER BY C.datetime_col desc) as A
GROUP BY A.id
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!