表 tb  有列 a b c d (a,b是主键,d是打酱油的)
求当 a和b相同的时候 如果c的数据出现不一样就查出来的怎么写

解决方案 »

  1.   

    select * from tb t
    where not exists(select 1 from tb n where t.a=n.a and t.b=n.b and t.c<>n.c)
      

  2.   

    a,b是主键l (联合主键),C的数据和谁比?和主键比?
    select * from tb where a=b and c!=a 
      

  3.   

    这个问题他没说清楚。如果你a,b为主键,就只能同一行数据a,b跟c比,因为表里面不会让你存在有两行a,b一样的数据。楼主给出测试数据和期待结果吧
      

  4.   

    我表达错了  我的意思是 a 和a相同的同时 b和b相同 然后要找出会出现c不相同的数据唉语文学不好 表达不清楚 不好意思啊
      

  5.   

    select * from tb t,tb n
    where  t.a=n.a and t.b=n.b and t.c<>n.c)
      

  6.   


    select * from tb t
    where not exists(select 1 from tb n where t.a=n.a and t.b=n.b and t.c<>n.c)那就是我一楼的那个意思