在PHP中通过联合订购

时间:2018-07-23 10:54:01

标签: php mysql sql-order-by union

我想使用order by语句,该语句为我提供排名靠前的结果。

intl.cpl

我想按ID desc按顺序获取输出,但是输出是错误的。

1 个答案:

答案 0 :(得分:0)

使用此查询对我有用。...

SELECT * 
FROM (SELECT content_update.id as id, 
             content_update.course_id as course_id, 
             content_update.status as status, 
             content_update.title as title, 
             content_update.img_src as img, 
             content_update.entry_date as entry_date 
      FROM content_update 

      UNION ALL 

      SELECT video_update.id as id, 
             video_update.course_id as course_id, 
             video_update.status as status,
             video_update.title as title, 
             video_update.video_link as img, 
             video_update.entry_date as entry_date 
      FROM video_update ) results 

ORDER BY entry_date DESC