2024-06-24 07:08:15
select t.* from
(select a.aa,xx,yy,zz,'b1' table_name from a,b1 where a.aa=b1.id and b1.n=23
union all
select a.aa,xx,yy,zz,'b2' table_name from a,b2 where a.aa=b2.id and b2.n=18
union all
select a.aa,xx,yy,zz,'b3' table_name from a,b3 where a.aa=b3.id and b3.n=25
union all
select a.aa,xx,yy,zz,'b4' table_name from a,b4 where a.aa=b4.id and b4.n=31) t
where t.aa=1或2或3或4
类似这样吧,把要查的所有内容都放到子查询里,子查询是各个查询的union all组合,最后通过aa来判断最后的查询结果。