有一表:newofitbl,其中主键为:以下前五个字段
newofinum newoficde,newcomcde,  newcde,            neweda,  newofisyscls
1         100022      00008     NEW00008-0000051      1       0
2         100022      00008     NEW00008-0000051      1       0
3         100022      00008     NEW00008-0000051      1       3
1         100023      00008     NEW00008-0000051      1       0现检索newofisyscls 不为3 且newoficde,newcomcde,newcde 与newofisyscls为3的那三个主键不出现

解决方案 »

  1.   

    就是凡是newofisyscls 为3的不检索出来,并且和newofisyscls =3 同为一样的那三个主键也不检索出来,拜托各位老大,帮帮忙
      

  2.   

    好吧 我来写一下吧  SQLSERVER2K 语法测试通过select * 
    from newofitbl 
    where
    newofisyscls <> 3
    and
    newoficde not in (select distinct newoficde from newofitbl where newofisyscls = 3)
    and 
    newcomcde not in (select distinct newcomcde from newofitbl where newofisyscls = 3)
    and
    newcde not in (select distinct newcde from newofitbl where newofisyscls = 3)
      

  3.   

    不要管为什么有多少个主键 
    我要的是select * from newofitbl where newofisyscls !=3 和 select * from newofitbl where (newcomcde,newcde,neweda) != (select newcomcde,newcde ,neweda from newofitbl where newofisyscls = 3)
    这两个的结合,怎么写?
      

  4.   

    select * 
    from newofitbl 
    where
    newofisyscls <> 3
    and
    (newoficde || newcomcde || newcde) not in (
              select distinct (newoficde || newcomcde || newcde)
              from newofitbl where newofisyscls = 3)试哈,自己没有测试
      

  5.   

    唔  楼主要得是newoficde,newcomcde,newcde三个同时都不符合还是三个分别都不符合?