繁体   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