select * from goodsorg where plucode in(select plucode from goods where plucode in(select plucode from goodsorg where (gcount+ccount)=0 and newxsdate is null and newjhdate is null ) and PluType = '0')未解部分是:
goddsorg表plucode列的数据和goods表中plucode列的数据一样,现在用的事in这个关键字,可是如果是包含的话,会出现多余的数据,请各位大大帮忙解决一下,谢谢了。我没分,希望大家见谅!

解决方案 »

  1.   

    试试这个
    select distinct a.* 
    from goodsorg a inner join goods b
    on a.plucode=b.plucode
    where (a.gcount+a.ccount)=0 
    and a.newxsdate is null and a.newjhdate is null
    and b.PluType = '0'
      

  2.   

    select m.* from goodsorg m , goods n 
    where m.plucode = n.plucode and (m.gcount+m.ccount)=0 and m.newxsdate is null and m.newjhdate is nullselect distinct m.* from goodsorg m , goods n 
    where m.plucode = n.plucode and (m.gcount+m.ccount)=0 and m.newxsdate is null and m.newjhdate is null