81,094
社区成员
发帖
与我相关
我的任务
分享
select t1.standardid,t1.standardname,t4.uperid,t4.context,t4.number
from table1 t1 right join
(
select t3.temp2id,t2.uperid,t2.context,t2.number
from table2 t2 left join
(
select temp2.id as temp2id,temp2.uperid as temp2uperid from table2 temp2 group by temp2.uperid order by temp2.id
) t3
on t2.id=t3.temp2id
) t4
on t4.uperid=t1.standardid and t4.temp2id is not null
select t1.standardid,t1.standardname,t4.uperid,t4.context,t4.number
from table1 t1 right join
(
select t3.temp2id,t2.uperid,t2.context,t2.number
from table2 t2 left join
(
select temp2.id as temp2id,temp2.uperid as temp2uperid from table2 temp2 group by temp2.uperid order by temp2.id
) t3
on t2.id=t3.temp2id
) t4
on t4.uperid=t1.standardid and t4.temp2id is not null