列出不带连接的不同列的数据

时间:2015-12-08 13:25:52

标签: mysql

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

1 个答案:

答案 0 :(得分:1)

您可能需要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