我不太清楚你的意思。 是不是想找出一個表中的數據不在另一個表中,然後再insert呀? 例: insert into table1 selct * from table2 where 信息 not in (select 信息 from table1 where ..).
没有那么复杂吧。 用MIUS SELECT * FROM TABLE1 MINUS SELECT * FROM TABLE2;得到TABLE1里有的但在TABLE2里没有的。
回复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条记录。
同意tuidler insert into tab1 SELECT * FROM TABLE1 MINUS SELECT * FROM TABLE2;
我没注意你的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.材质分类=‘中成药';
是不是想找出一個表中的數據不在另一個表中,然後再insert呀?
例:
insert into table1 selct * from table2 where 信息 not in (select 信息 from table1 where ..).
用MIUS
SELECT * FROM TABLE1
MINUS
SELECT * FROM TABLE2;得到TABLE1里有的但在TABLE2里没有的。
是呀!我用以下语句:
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条记录。
insert into tab1
SELECT * FROM TABLE1
MINUS
SELECT * FROM TABLE2;
两个表的字段不一样,yaofypkxcc表中只用一个yaopbh字段。
非常不错,谢谢。