簡體   English   中英

從具有不同順序列的兩個表中選擇

[英]Select from two tables with different order column

我有兩個表,每個表三列:

  • tbl_music (id, title, reg_time)
  • tbl_movie (id, title, time_log)

對於sitemap.xml我想按時間按文件順序添加兩個表中的所有項目。 這兩個表是分開的,時間字段是reg_timetime_log

如何連接兩個表並從兩個表上的值排序?

在以下情況下,結果集包括tbl_musictbl_movie表的內容

select * from 
( select id, title, reg_time as time from tbl_music 
  union all
  select id, title, time_log as time from tbl_movie
) results
order by time

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM