方式一:
select * from
(select * from tab1 where sj between '2014-08-31' and '2014-08-31'
union all
select * from tab2 where sj between '2014-08-31' and '2014-08-31'
union all
select * from tab3 where sj between '2014-08-31' and '2014-08-31'
union all
select * from tab4 where sj between '2014-08-31' and '2014-08-31') tab
方式二:
select * from
(select * from tab1
union all
select * from tab2
union all
select * from tab3
union all
select * from tab4 ) tab between '2014-08-31' and '2014-08-31'
那种方式更效率?还是一样?
------解决方案--------------------
测试了,完全一样
------解决方案--------------------
比如:查找4张纸上的数据,你分开摆放在桌上一张一张看查看 快。
还是先把4张纸 订一起,然一张一张的看快。
————
同理:你四张表都要between '2014-08-31' and '2014-08-31'
所以一样。
------解决方案--------------------
查询优化器 ,优化了两种写法 ,最后的执行计划是一样的。
但是 第一中更加直观。