2015-09-17 47 views
-2

我有每三列的兩個表:從不同的順序列兩個表選擇

  • tbl_music(ID,標題,reg_time)
  • tbl_movie(ID,標題,time_log)

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

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

+3

使用[UNION ALL](https://msdn.microsoft.com/en-GB/library/ ms180026.aspx) – Kaf

回答

1

在以下的情況下,結果集合包括兩個內容的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 
相關問題