0

Can anyone tell me why the following SQL refuses to insert more than 1 result (using sqlite3)? And how to make it insert all distinct values from the select port_shipment?
The cargo table in this database contains more than 2000 distinct values for port_shipment, but I tried several versions of the insert-command which resulted always in only 1 value inserted.

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))

Thanks!

1 Answer 1

2

The values statement is not needed with select. Try this:

insert or ignore into port (port_ID, port_description) 
    SELECT NULL, port_shipment
    FROM cargo
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.