Table t1
 a          b
--------------- ---------------
1          2
3          2
Table t2
a           b
----------------- ---------------
1           1
3           2怎样返回T1表中a=1,b=2这条记录?谢谢!

解决方案 »

  1.   

    select t1.* from t1,t2 where t1.a = t2.a and t2.a = t2.b
      

  2.   

    select * from T1 where a=1 and b=2跟T2有什么关系啊
      

  3.   

    create table t1(a int,b int)
    insert into t1 values(1,2) 
    insert into t1 values(3,2) 
    create table t2(a int,b int)
    insert into t2 values(1,1) 
    insert into t2 values(3,2) 
    go
    select t1.* from t1,t2 where t1.a = t2.a and t2.a = t2.b
    drop table t1,t2/*
    a           b           
    ----------- ----------- 
    1           2(所影响的行数为 1 行)
    */
      

  4.   

    create table #t1(a int,b int) insert into #t1 values(1,2)  
    insert into #t1 values(3,2)  create table #t2(a int,b int) insert into #t2 values(1,1)  
    insert into #t2 values(3,2)  
    go 
    select a.*
    from #t1 as a 
        left join  #t2 as b on a.a=b.a and a.b=b.b
    where b.a is null or b.b is nulldrop table #t1,#t2
      

  5.   

    select * from T1 t
    where not exists(select * from T2 where a=t.a and b=t.b)  --这个意思?
      

  6.   

    select * from t1 where not exists(select 1 from t2 where a=t1.a and b=t1.b)
      

  7.   

    select a.* from t1 a inner join t2 b on a.a=b.a where a.b!=b.b
    是这个意思吧
      

  8.   

    select a.* from t1 a inner join t2 b on a.a=b.a where a.b!=b.b
    是这个意思吧