张御扬

博客园 首页 新随笔 联系 订阅 管理

对于union的sql语句 尽量做到同类归并

例如:

select ..

from A,B,C,D1

where conditon on D1

and (joins and other conditons)

union

select ..

from A,B,C,D2

where condtion on D2

and (joins and other conditons)
为提高效率
select ..
from
A,B,C,
(
select .. from D1 where conditon on D1
union
select .. from D2 where condition on D2
)D

where joins and other conditons
posted on 2011-02-23 23:48  张御扬  阅读(138)  评论(0)    收藏  举报