请教各位高手一SQL语句:我有两个表,其中一是jidiaogondan
另表是shengchanx,现在要查找shengchanx的两字段gongdanhao\proid,同时要求gongdanhao\proid不是在jidiaogondan表的!!(注gongdanhao和proid一起才能确定一记录,确定一条记录的)
例如:
我的意思是查找shengchanx表的记录但同时不在jidiaogondan表的记录!
shengchanx表有如下两记录
      gongdanhao    proid
记录1:082933/2006  AJS02C084B05  
记录2:082933/2006  AJS02C084S05

解决方案 »

  1.   

    select from gongdanhao,proid from shengchanx where gongdanhao+proid as myid not in
    (select gongdanhao+proid from jidiaogondan)
      

  2.   

    select from gongdanhao,proid from shengchanx where gongdanhao+proid as myid not in
    (select gongdanhao+proid from jidiaogondan)正解
      

  3.   

    select gongdanhao,proid from shengchanx where gongdanhao,proid  not in  (select gongdanhao,proid from jidiaogondan)
    楼主试试看,我没试!
      

  4.   

    select from gongdanhao,proid from shengchanx where gongdanhao+proid as myid not in
    (select gongdanhao+proid from jidiaogondan)???不明白?
    我改为select gongdanhao,proid from shengchanx where gongdanhao+proid as myid not in
    (select gongdanhao+proid as myid from jidiaogondan)也不行
      

  5.   

    select gongdanhao,proid from shengchanx where gongdanhao,proid  not in  (select gongdanhao,proid from jidiaogondan)
      

  6.   

    linzhisong(無聊) select from gongdanhao,proid from shengchanx where gongdanhao+proid as myid not in
    (select gongdanhao+proid from jidiaogondan)
    是不是想将两字段化为一字段??我还没见过这种写法,可试了,好像不通!
      

  7.   

    借宝地一用,北京门户网站,招asp.net程序员[email protected],待遇不错,不用加班,工作开心,不诚勿扰,谢谢!
      

  8.   

    楼主,那个两个字段其中有没有一个能唯一标识记录啊,如果能的话就用一个字段.
       字段 not in (select * from ---)如果只有一个字段  not in 是可以实现的
      

  9.   

    就是没有唯一的字段啊!gongdanhao工单号,而proid是产品编号,这些都不是唯一的!
    同一产品就同一产品编号,所以一产品编号proid可以对多个gongdanhao工单号!当同一产品时,也可有几个单号,只有两者才唯一!
      

  10.   

    yuwenge(活得痛快):select from gongdanhao,proid from shengchanx where gongdanhao+proid not in(select gongdanhao+proid from jidiaogondan)
    是OK的!谢谢各位