哇,union的优先级很高嘛

阅读 69

2022-08-15


原来,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]



精彩评论(0)

0 0 举报