Mysql - 2 个表按 date_posted 排序
Mysql - 2 tables sort by date_posted
我的 sql
中有 2 个 table
Instagram
- id
- url
-字幕
- 图片
- date_posted
推特
- screen_name
- 文字
- date_posted
发布的数据是 unix 时间戳。 data_posted 检索和排序的最佳方法是什么?
我想我有几个选择
一个 table 有一些空白字段(例如 screen_name 是一个仅限 Twitter 的字段)
a table 创建连接。
将它们都检索到一个数组中并尝试在那里排序。
如有任何关于最佳方法的想法,我们将不胜感激。
试试这个:
SELECT *
FROM (
SELECT id, url_caption, image, '' as screen_name,'' as text,date_posted FROM instagram
UNION
SELECT 0 as id, '' as url_caption, '' as image, screen_name,text, date_posted FROM twitter)
ORDER BY date_posted
我的 sql
中有 2 个 table- id
- url -字幕
- 图片
- date_posted
推特
- screen_name
- 文字
- date_posted
发布的数据是 unix 时间戳。 data_posted 检索和排序的最佳方法是什么?
我想我有几个选择
一个 table 有一些空白字段(例如 screen_name 是一个仅限 Twitter 的字段)
a table 创建连接。
将它们都检索到一个数组中并尝试在那里排序。
如有任何关于最佳方法的想法,我们将不胜感激。
试试这个:
SELECT *
FROM (
SELECT id, url_caption, image, '' as screen_name,'' as text,date_posted FROM instagram
UNION
SELECT 0 as id, '' as url_caption, '' as image, screen_name,text, date_posted FROM twitter)
ORDER BY date_posted