2013-06-12 63 views
0

誰能告訴我爲什麼以下SQL拒絕插入多於1個結果(使用sqlite3)?以及如何使它從選擇的port_shipment中插入所有不同的值?
此數據庫中的貨物表包含超過2000個不同的port_shipment值,但我嘗試了插入命令的多個版本,結果總是隻插入1個值。SQLite:insert with select

create table port (
    port_ID integer not null primary key, 
    port_description text unique collate nocase, 
    port_name text, 
    country text, 
    lat text, 
    lon text 
) 

insert or ignore into port (port_ID, port_description) 
values (null, (SELECT port_shipment FROM cargo)) 

謝謝!

回答

0

values聲明不需要與select。試試這個:

insert or ignore into port (port_ID, port_description) 
    SELECT NULL, port_shipment 
    FROM cargo 
+0

謝謝,這個工作! – Hans