b a c
1 1 2
1 2 2
1 3        2
1        0        3
要求可以把最后一条过滤掉,该怎么改呢

解决方案 »

  1.   

    你看到我给的例子了么
    就是这两个条件(a=0 or a=2)和b in (select b from table1 where a =1 or a =3)
    里要加入c的关联.这两个条件里的c要求是相等的
      

  2.   

    是这个意思吗?
    select * from table1
    join (select * from table1 where a=1 or a=3)k
    on b = k.b and c=k.c
    where a=0 or a=2
      

  3.   

    select * from (select * from table1 where a=0 or a=2 and b in (select b from table1 where a =1 or a =3))t where c=t.c 
      

  4.   

    to  lsp69(浪子神剑)你的也提示t有语法错误
    怎么这样
      

  5.   

    select * 
    from table1 a
    where (a=0 or a=2) 
      and exists(select 1 
                 from table1 b 
                 where (a =1 or a =3) 
                   and a.b=b.b
                   and a.c=b.c)
      

  6.   

    lsqkeke(可可) 和 zhang_yzy(六子儿) 都可以
    后者的效果更好点能不能给我解释下
    给你们加分~~