有两个查询语句,如下:
select * from t where a<>'2'select * from t where b='false'现在想通过一条sql语句把上面两个语句查询到的结果合并到一个临时表#tem中,求该语句该如何写..先谢谢了。

解决方案 »

  1.   


    select * into #tem from t where a <>'2' and b='false'
    --or
    select * into #tem from (
    select * from t where a <>'2'
    union 
    select * from t where b='false' ) 
      

  2.   

    insert ino
    select * from t where a <>'2' 
    union all
    select * from t where b='false' 
      

  3.   

    select * INTO #TEMP from t where a <>'2'
    UNION ALLselect * from t where b='false' 
      

  4.   

    表的结构需要一样。select * into #temp from t where a<>'2' 
    insert into #temp 
    select * from t where b=false
      

  5.   


    select * into #tem
    from 
       (select * from t where a <>'2' 
       union all 
       select * from t where b='false')tb 
      

  6.   

    select * from t where a <>'2' 
    union 
    select * from t where b='false'
      

  7.   

    UNION在进行表链接后会筛选掉重复的记录
    而UNION ALL只是简单的将两个结果合并后就返回。这样,如果返回的两个结果集中有重复的数据,那么返回的结果集就会包含重复的数据了。