select *from (select 1 as id union all select 2 as id) t1
union all
select * from (select 3 as id union all select 4 as id)t2 where id > 3 ;
-- 这个where条件只对下面的sql起作用。如果使用了()子表查询,那么【where id > 3】会对整个结果起作用
-- 结果是
4
2
1
select 3 as id
union all
select 4 as id
from (select 5 as id )t1where id > 4 ;
结果:
id
3
4
select 3 as id union all select 4 as id
from (select 4 as id )t1where id > 4 ;
结果:
id
3
end