union中的order by的应用
来源:互联网 发布:英伟达游戏优化软件 编辑:程序博客网 时间:2024/06/05 12:03
只能在union的最后一个子句后使用order by,并且此时order by的作用对象是union后的整个结果集。
如果子查询的列名不相同,如:
select A,Bfrom tableAunionselect C,Dfrom tableB
此时如果在第二个子查询后加上"order by C"就会报错,这种情况只能使用"order by A"。因为union后结果集的列名取的是第一个子查询的列名。
为了避免出现上面的错误可以采用下面的方法
1.统一所有子查询的列名
select A,Bfrom tableAunionselect C as A,D as Bfrom tableBorder by A2.使用列序号代替列名
select A,Bfrom tableAunionselect C,Dfrom tableBorder by 1
0 0
- union中的order by的应用
- 关于union的order by
- order by union 应用实例 mssql
- mysql中的union和order by、limit
- mysql中的union和order by、limit
- Oracle中的union与order by
- UNION中ORDER By的使用
- UNION ALL ORDER BY的问题
- UNION中ORDER By的使用
- union中order by的使用
- UNION中ORDER By的使用
- Union与order by
- ORACLE union order by
- union 或者 union all 与 order by 的联合使用
- oracle order by 和union all(union)的使用
- SQL Union 与Order By
- Union 中使用Order by
- union与union all与order by
- 正则表达式30分钟入门教程
- 判断字符串为空以及转换空字符串
- Android之UI自适应解决方案
- Java AWT基础及布局管理
- oracle11g突然连不上了,ora-12514 和 ora-27101
- union中的order by的应用
- HDU1713 gcd
- 无线通信系统DIY
- 职场新人成长宝典
- [c.y.j]转载 linux 硬盘挂载
- 单例设计模式与静态类,静态方法的联系
- JAVA IP地址转成长整型方法
- 使用CocoaPods(二)删除已经配置的类库和移除CocoaPods
- 最长回文子串