日期:2014-05-19  浏览次数:20533 次

union 的问题
a   表
  cu_id   cur_name   date
  1             abc             2006
  2             def             2007
  5               efg           2008
b   表
cur_id     cur_name   date    
1               abc             2007        
1               abc             2007        
3               def             2008        

用a   union     b   时
线保证     b   里边的数据  
也就是   b   里边要是有的话
union   后的结果就是   b   的数据
a   表和表合并后为

1               abc             2007        
1               abc             2007        
3               def             2008    
5               efg           2008



------解决方案--------------------
seelct * from b
union all
select * from a
where not exists (
select 1 from b where
cur_name =a.cur_name
)