gpt4 book ai didi

mysql - 同一张表上的多个 order by

转载 作者:行者123 更新时间:2023-11-29 13:01:30 25 4
gpt4 key购买 nike

假设我有 3 个简单的选择:

select * from `table` order by `id` desc limit 10

select * from `table` order by `date` desc limit 10

select * from `table` order by `name` desc limit 10

是否可以将这三个查询合并到一个查询中?

谢谢

最佳答案

您可以使用union all:

(select * from `table` order by `id` desc limit 10)
union all
(select * from `table` order by `date` desc limit 10)
union all
(select * from `table` order by `name` desc limit 10);

关于mysql - 同一张表上的多个 order by,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23270442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com