哇,union的优先级很高嘛

原来,union的优先级很高。比如

select stdname,[subject]='化学',化学 as score  from #student2 
union all 
select stdname,[subject]='数学',数学 as score  from #student2 
union all 
select stdname,[subject]='物理',物理 as score  from #student2 
union all 
select stdname,[subject]='语文',语文 as score  from #student2 
order by stdname,[subject]

等同于

select * from(
select stdname,[subject]='化学',化学 as score  from #student2 
union all 
select stdname,[subject]='数学',数学 as score  from #student2 
union all 
select stdname,[subject]='物理',物理 as score  from #student2 
union all 
select stdname,[subject]='语文',语文 as score  from #student2 
) as a
order by stdname,[subject]


posted on 2013-06-15 17:56  左直拳  阅读(260)  评论(0编辑  收藏  举报

导航