gpt4 book ai didi

mysql - 列出来自不同列的数据,无需连接

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

我有 3 个表,每个表中都有一个“日期”列。如何从这些列中检索按日期排序的数据?谢谢。

最佳答案

您可能需要 UNION ALL 查询。像这样的事情:

SELECT id, date, 'photo' as type FROM photoes
UNION ALL
SELECT id, date, 'comment' as type FROM comments
UNION ALL
SELECT id, date, 'like' as type FROM likes
ORDER BY date DESC
LIMIT 10

关于mysql - 列出来自不同列的数据,无需连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34157099/

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