导航

[SQL] 不合并重复数据 union all

Posted on 2014-03-25 19:19  beeone  阅读(2565)  评论(0编辑  收藏  举报
select   *   from   A   
  union     
  select   *   from   B   
    
    
    
  --不合并重复行   
  select   *   from   A   
  union   all   
  select   *   from   B   
    
    
  --如果要对字段进行排序   
  select   *   
  from   (   
  select   id,...   from   A   
  union   all   
  select   id,...   from   B   
  )   t   
  order   by   ID