select table1.* from table1 left join table2 on table2.id in (
select max(id) from table2 where id = table1.relate_id
) and table1.relate_id = table2.id
SQL Left Join 右表取最新一条数据
于 2023-02-22 11:54:22 首次发布
select table1.* from table1 left join table2 on table2.id in (
select max(id) from table2 where id = table1.relate_id
) and table1.relate_id = table2.id