if exists (
select 1 from marcidx a where a.f1= '010a' and a.f2 = '7-5053-7707-8'
and exists (
select 1 from marcidx b where b.f1= '200a' and b.f2 = 'vb6.0程序设计'
and b.id = a.id
)
)
begin
insert marcidx(id,f1,f2) values('001','010a','7-5053-7707-8')
insert marcidx(id,f1,f2) values('001','200a','vb6.0程序设计')
insert marcidx(id,f1,f2) values('001','200a','吉林人民出版社')
end
insert into marcidx(id ,f1,f2)
select * from(
select '003' id,'010a' f1,'7-5053-7707-8' f2
union
select '003','200a','vb6.0程序设计'
union
select '003','210c','XX出版社'
)t where not exists(select 1 from marcidx where f2='7-5053-7707-8')
and not exists(select 1 from marcidx where f2='vb6.0程序设计')
--如果只要用id 来比较的话,那只要写一句 where not exists(select 1 from marcidx where id='003')
------解决方案--------------------
where not exists(select 1 from marcidx where f2='7-5053-7707-8')
and not exists(select 1 from marcidx where f2='vb6.0程序设计')