实际上我陷入了一些mysql代码的中间.谁能提出一个简单的问题.我在数据库中有6-10个(多个)表,它们具有不同的数据意味着彼此不相关.
表之间没有关系,但是在所有表的每个列中都插入了时间.我想要的只是查询按时间列排序的所有表.
例如:
table1:
recipename | cook | timetocook | dated (auto posted time - php time())
-----------+------+------------+------
abc | def | 100 | 10
zxy | orp | 102 | 16
Run Code Online (Sandbox Code Playgroud)
表2:
bookname | author | dated (auto posted time - php time())
---------+--------+------
ab | cd | 11
ef | nm | 14
Run Code Online (Sandbox Code Playgroud)
你可以看到表之间没有任何关系(我已经阅读过关于连接的内容),我想根据asc到desc的发布时间逐个显示数据.
像这样:
abc def 100 10
ab cd 11
ef nm 14
zxy orp 102 16
Run Code Online (Sandbox Code Playgroud)
所以任何帮助...实现这一点???
SELECT recipename, cook, timetocook, dated
FROM table1
UNION
SELECT bookname, author, dated, NULL
FROM table2
ORDER BY dated
Run Code Online (Sandbox Code Playgroud)
您必须添加NULL值以确保列计数与订单表相同.
| 归档时间: |
|
| 查看次数: |
931 次 |
| 最近记录: |