我有3个表,每个表中都有一个“date”列。如何从按日期排序的这些列中检索数据?谢谢。
答案 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