首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

union 的有关问题

2012-02-27 
union 的问题a表cu_idcur_namedate1abc20062def20075efg2008b表cur_idcur_namedate1abc20071abc20073def20

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
)

热点排行