Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL error or missing database (table destination has x columns but y values were supplied)

Tags:

sqlite

I have 2 tables "Source" and "Destination" that have the same fields, except for the destination having an extra 'date' field

I need to copy the all the fields to their corresponding fields in destination leaving date blank.

I tried:

INSERT INTO Destination SELECT * FROM Source

got :

[SQLITE_ERROR] SQL error or missing database (table destination has 18 columns but 17 values were supplied). 

How can I make this work?

like image 216
user1592380 Avatar asked Aug 01 '17 20:08

user1592380


1 Answers

The error message is pretty clear - you're trying to insert 17 values into a table with 18 columns and SQL doesn't know what you intend.

You fix that by specifying those columns explicitly, e.g.:

INSERT INTO Destination(field1, field2, ... field17)
SELECT field1, field2, ... field17
FROM Source;
like image 173
varro Avatar answered Nov 15 '22 08:11

varro