union all 后面的orderby
时间: 2023-08-25 22:09:01 浏览: 96
UNION ALL后面的ORDER BY在这个SQL语句中是无效的。\[2\]UNION ALL只是简单地将两个结果集连接在一起,不会进行筛选排重的操作。所以,如果想要对整个结果集进行排序,可以在最外层的SELECT语句中使用ORDER BY来实现。
#### 引用[.reference_title]
- *1* *3* [sql server union all 后 order by 小记](https://blog.csdn.net/qq_35972907/article/details/109574634)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [MYSQL中UNION/UNION ALL与ORDER BY不能公用问题](https://blog.csdn.net/csdn_halon/article/details/118497578)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文