select * from j01 union select * from j02 union select * from j03
select * from (select * from j01 union select * from j02 union select * from j03)
知道查几个月(x) 判断01到x表是否存在,得到对应表名 循环表名得到语句select id, sum(qty) from (select id,qty from j01 union select id,qty from j02 union select id,qty from j03 ) table1 group by id
select id,qty from j01 union select id,qty from j02 union select id,qty from j03
select * from j01 where ... union select * from j02 where ... union select * from j03 where ... order by ...
union
select * from j02
union
select * from j03
select * from j02 union
select * from j03)
判断01到x表是否存在,得到对应表名
循环表名得到语句select id, sum(qty) from
(select id,qty from j01
union
select id,qty from j02
union
select id,qty from j03
) table1 group by id
union
select id,qty from j02
union
select id,qty from j03
union
select * from j02 where ...
union
select * from j03 where ...
order by ...