0
点赞
收藏
分享

微信扫一扫

哇,union的优先级很高嘛

程序员阿狸 2022-08-15 阅读 68


原来,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 条评论