各位好
请教个问题
库中有
log_2008_02
log_2008_03
log_2008_043个表结构字段相同,怎么合起来查询 ?比如
第一个表
id name
1   aa第二个表 id  name
2   bb第三个表 id name 
3  cc想合成一个表 id name 
1  aa
2  bb
3  cc然后查询

解决方案 »

  1.   

    select id,name from [log_2008_02]
    union all
    select id,name from [log_2008_03]
    union all
    select id,name from [log_2008_04]
      

  2.   

    用 Union吧select id,name from log_2008_02 
    group by id,name 
    union
    select id,name from log_2008_03 
    group by id,name 
    union
    select id,name from log_2008_04 
    group by id,name 
      

  3.   


    select id,name from [log_2008_02]
    union all
    select id,name from [log_2008_03]
    union all
    select id,name from [log_2008_04]union 并集 
    intersect 交集
    execpt 差集
      

  4.   


    union all 并集
    union 并集,去掉重复记录
      

  5.   


    select * from 表1
    union all 
    select * from 表2
    union all 
    select * from 表3