在sql中使用带有三个UNION的Order By

时间:2018-03-22 13:01:58

标签: php mysql sql

我有三个联盟,我需要订购它们或使用另一个查询:

class Router{  \\ on main thread
static  Link[] ports = new Link[4];

 void processCnnect {
 else if(Router.ports[i]==null && processPort > 1023 && processPort<=65535)
          {
   Router.ports[i] =new Link(rd,rd_c); 
        }
}

class ServerThread extends Thread
{
                           // reading then updating Router.ports[]
}
There are some threads which perform heart beat mechanism by sending packets to other consumer (receiver) like alive messages. Its a mix of multi threading and  socket programming.

My episode table

movie table

series table

1 个答案:

答案 0 :(得分:0)

对于UNION,您必须使用相同数量的列和匹配的数据类型

对缺席列使用null

我建议你使用左连接

来反转表名
SELECT episode.episode_id
  , episode.ep_title
  , episode.post_date 
  , series.series_id
  , series.title
  , series.pic 
FROM series
LEFT  JOIN episode ON episode.series_oid=series.series_id 
UNION ALL 
SELECT mov_id
, mov_title
, post_date
, null
, null
, null 
FROM movies 
ORDER BY post_date