2012-05-30 28 views

回答

4
insert into OPT  (email,  campaign_id) 
select '[email protected]' as email, 100 as campaign_id from dual MINUS 
select     email,  campaign_id from OPT; 

如果已經存在用一記[email protected]/100在OPT中,MINUS將從select '[email protected]' as email, 100 as campaign_id from dual記錄中減去此記錄,並且不會插入任何內容。另一方面,如果沒有這樣的記錄,則MINUS不會扣分任何東西,並且將插入值[email protected]/100

由於p.marino已經指出的那樣,merge可能是你的問題的更好(更正確)的解決方案,因爲它是專門設計來解決你的任務。