我不是很清楚你的目的
看看这样 select 信息.name from 信息 where 信息.name not in (select distinct (库存.name) from 库存);
把库存中没有的药品名称找出来,再作你想做的事情

解决方案 »

  1.   

    我不太清楚你的意思。
    是不是想找出一個表中的數據不在另一個表中,然後再insert呀?
    例:
    insert into table1 selct * from table2 where 信息 not in (select 信息 from table1 where ..).
      

  2.   

    没有那么复杂吧。
    用MIUS
    SELECT * FROM TABLE1 
    MINUS 
    SELECT * FROM TABLE2;得到TABLE1里有的但在TABLE2里没有的。
      

  3.   

    回复benxie
    是呀!我用以下语句:
    insert into yaopkcxx values('c-01','select y.yaopbh from yaofypkcxx f,yaopxx y where y.yaopbh=f.yaopbh and y.材质分类=‘中成药’',0,0,0,0,0,100000,0)
    但提示:select语句没有完成。
    我用select y.yaopbh from yaofypkcxx f,yaopxx y where y.yaopbh=f.yaopbh and y.材质分类=‘中成药语句查询时查到192条记录。
      

  4.   

    同意tuidler
    insert into tab1
    SELECT * FROM TABLE1 
    MINUS 
    SELECT * FROM TABLE2;
      

  5.   

    我没注意你的sql是否正确,如果想达到这种目的的话,要这么用:insert into yaopkcxx select 'c-01',y.yaopbh,0,0,0,0,0,100000,0 from yaofypkcxx f,yaopxx y where y.yaopbh=f.yaopbh and y.材质分类=‘中成药';
      

  6.   

    回复zuhuisu
    两个表的字段不一样,yaofypkxcc表中只用一个yaopbh字段。
      

  7.   

    回复snowy_howe
    非常不错,谢谢。