union与union all与order by
来源:互联网 发布:淘宝模板大寸好吗 编辑:程序博客网 时间:2024/05/16 07:02
有时候我们会将两部分排序的结果联合起来显示,union会自动排序和去重,union all则不会
看以下sql语句:
select a,b,c from AA aa where ...... order by aa.a desc
union all
select a,b,c from BB bb where ...... order by bb.a desc
会报错,原因是union all 最后一个select才能orderby 或者就嵌套一层再order by,如下:
select * from (select a,b,c from AA aa where ...... order by aa.a desc)
union all
select * from (select a,b,c from BB bb where ...... order by bb.a desc)
0 0
- union与union all与order by
- union 或者 union all 与 order by 的联合使用
- Union与order by
- MySQL 之union all 与 order by 同时出现问题
- SQL Union 与Order By
- UNION与UNION ALL
- Union 与 Union ALl
- union 与 union all
- union 与union all
- union与union all
- union 与 union all
- SQL Union和SQL Union All两者用法区别效率以及与order by 和 group by配合问题
- 数据库:UNION 与 UNION ALL
- UNION与UNION ALL 区别
- oracle Union 与 union all
- oracle union 与 union all
- 【数据库】UNION与UNION ALL
- union all 与 union 区别
- ARM的SDRAM、LED、中断硬件原理及源程序
- 复习java基础第一天
- Eclipse安装Maven插件
- linux后台运行jar程序的方法
- fmdb
- union与union all与order by
- 调用系统相机拍照,裁剪图片
- mysql数据库无法连接(JDBC)java.net.ConnectException: Connection timed out
- 如何使用 DevExpress MVVM 架构构建具有 DOCK 能力的 MVVM 程序?
- 相对路径 VS 绝对路径
- mysql算两个日期之间的工作日
- nyoj 547 优先队列
- Excel函数大全
- NYOJ 117 求逆序数