![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Comparing the fields in "births"with the fields defined by the SELECT, The only field that is missing is the primary key (birthid), which I assumed the INSERT would fill in.. |
#3
| |||
| |||
|
|
I have a table that I want to copy selected fields into another table. The footprint of the tables is different. Here is the INSERT I am trying to use. An error is returned, "SQL Error (1136); Column count doesn't match value count at row 1. I've run the SELECT without the INSERT line and it does select the data I want to copy. Comparing the fields in "births"with the fields defined by the SELECT, The only field that is missing is the primary key (birthid), which I assumed the INSERT would fill in.. |
|
INSERT IGNORE INTO births SELECT |
#4
| |||
| |||
|
|
El 04/03/2011 3:47, bruce escribi /wrote: I have a table that I want to copy selected fields into another table. The footprint of the tables is different. Here is the INSERT I am trying to use. An error is returned, "SQL Error (1136); Column count doesn't match value count at row 1. I've run the SELECT without the INSERT line and it does select the data I want to copy. Comparing the fields in "births"with the fields defined by the SELECT, The only field that is missing is the primary key (birthid), which I assumed the INSERT would fill in.. Nope, that's not how INSERT works. You just cannot do this: INSERT INTO foo (id, bar) VALUES ('Hello'); INSERT IGNORE INTO births SELECT Are you aware that if you ever add new columns to the births table your application will stop working and if you ever swap columns you application will start storing invalid data? -- --http://alvaro.es- lvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programaci n web:http://borrame.com -- Mi web de humor satinado:http://www.demogracia.com -- |
#5
| |||
| |||
|
|
Basically I solved the problem by deleting the two "extra' columns in the target table, namely the primary key column and the one data column I'll be updating later in the application. |
|
The data then loaded. After that I added back the these two columns. All is good.. |
#6
| |||
| |||
|
|
El 04/03/2011 3:47, bruce escribi?/wrote: I have a table that I want to copy selected fields into another table. The footprint of the tables is different. Here is the INSERT I am trying to use. An error is returned, "SQL Error (1136); Column count doesn't match value count at row 1. I've run the SELECT without the INSERT line and it does select the data I want to copy. Comparing the fields in "births"with the fields defined by the SELECT, The only field that is missing is the primary key (birthid), which I assumed the INSERT would fill in.. Nope, that's not how INSERT works. You just cannot do this: INSERT INTO foo (id, bar) VALUES ('Hello'); |
![]() |
| Thread Tools | |
| Display Modes | |
| |