copy data from one table to another table [message #172820] |
Fri, 04 March 2011 02:39 |
bruceaj
Messages: 30 Registered: September 2010
Karma: 0
|
Member |
|
|
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..
USE genealogyvr;
INSERT IGNORE INTO births
SELECT
NewspaperKey AS newspaperid,
CONCAT(Year, "-",
IF(Month < 10, CONCAT("0",Month), Month) ,
"-" ,
IF(Day < 10, CONCAT("0", Day), Day) ) AS paperdate,
Page AS page,
Col AS col,
FatherFirst AS fatherfirst,
FatherMiddle AS fathermiddle,
MotherFirst AS motherfirst,
MotherMiddle AS mothermiddle,
MotherMaiden AS mothermaiden,
First AS childfirst,
Middle AS childmiddle,
Last AS childlast,
DateOfBirth AS dob,
Comments AS comment
FROM birthsaccess
WHERE Year < 1890;
|
|
|
Re: copy data from one table to another table [message #172821 is a reply to message #172820] |
Fri, 04 March 2011 02:43 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/3/2011 9:39 PM, bruceaj 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..
>
> USE genealogyvr;
>
> INSERT IGNORE INTO births
> SELECT
> NewspaperKey AS newspaperid,
> CONCAT(Year, "-",
> IF(Month< 10, CONCAT("0",Month), Month) ,
> "-" ,
> IF(Day< 10, CONCAT("0", Day), Day) ) AS paperdate,
> Page AS page,
> Col AS col,
> FatherFirst AS fatherfirst,
> FatherMiddle AS fathermiddle,
> MotherFirst AS motherfirst,
> MotherMiddle AS mothermiddle,
> MotherMaiden AS mothermaiden,
> First AS childfirst,
> Middle AS childmiddle,
> Last AS childlast,
> DateOfBirth AS dob,
> Comments AS comment
>
> FROM birthsaccess
> WHERE Year< 1890;
This is a PHP newsgroup (hence the "php" in it's name).
Try a newsgroup related to the database you're using.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: copy data from one table to another table [message #172822 is a reply to message #172821] |
Fri, 04 March 2011 02:49 |
bruceaj
Messages: 30 Registered: September 2010
Karma: 0
|
Member |
|
|
On Mar 3, 9:43 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 3/3/2011 9:39 PM, bruceaj 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..
>
>> USE genealogyvr;
>
>> INSERT IGNORE INTO births
>> SELECT
>> NewspaperKey AS newspaperid,
>> CONCAT(Year, "-",
>> IF(Month< 10, CONCAT("0",Month), Month) ,
>> "-" ,
>> IF(Day< 10, CONCAT("0", Day), Day) ) AS paperdate,
>> Page AS page,
>> Col AS col,
>> FatherFirst AS fatherfirst,
>> FatherMiddle AS fathermiddle,
>> MotherFirst AS motherfirst,
>> MotherMiddle AS mothermiddle,
>> MotherMaiden AS mothermaiden,
>> First AS childfirst,
>> Middle AS childmiddle,
>> Last AS childlast,
>> DateOfBirth AS dob,
>> Comments AS comment
>
>> FROM birthsaccess
>> WHERE Year< 1890;
>
> This is a PHP newsgroup (hence the "php" in it's name).
>
> Try a newsgroup related to the database you're using.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
Okay.. Okay..
How about going over the mysql newsgroup where I've posted this
problem??
Thanks..
Bruce
|
|
|