2012-07-20 53 views
-1

在其中空值忽略的記錄,我有以下表格:與插入

發明家(inventorID專利號,InventorFirst,InventorLast,市,州)

其中inventorid是PK,專利號是fk。

這是當前的插入代碼:

insert into Inventor (PatentNo, InventorFirst, InventorLast, City, statename, country, NationalityCountry, ResidenceCountry) 
select PatentNo, InventorFirstname, InventorLastname, City, statename, country, NationalityCountry, ResidenceCountry 
from InventorUpdate; 

我想修改此,這樣,如果InventorFirstname & InventorLastname字段爲空,則它不插入發明者表

回答

3

你怎麼樣保持記錄這些字段爲空而不被選擇?

insert into Inventor (PatentNo, InventorFirst, InventorLast, City, statename, country, NationalityCountry, ResidenceCountry) 
select PatentNo, InventorFirstname, InventorLastname, City, statename, country, NationalityCountry, ResidenceCountry 
from InventorUpdate 
Where InventorFirstname is not null 
And InventorLastname is not null; 
+0

哦,這個男人,這讓我笑...這樣一個簡單的問題,我試圖拼命去複雜...謝謝你@丹尼爾庫克! – 2012-07-20 00:40:44