select *from table1 order by (select conut(1) from table2 where table2.id=table1 .id desc)

2024-11-28 22:50:22
推荐回答(2个)
回答1:

select t.* from tb1 as t
left join
(select id,count(id) as n from tb2 group by id) as a1
on t.id=a1.id
order by a1.n

回答2:

hql 的时候要把select * 去掉