smoothcat11
asked on
Add an ID to a Table w/ Auto Increment
Hello, I have 2 tables that I uploaded. They have the same fields, but no id. I want to combine them in a new table and I need to add an id to the table:
Table 'ContactsPart1':
first_name, last_name, phone
Table 'ContactsPart2':
first_name, last_name, phone
I want it to be:
Table 'ContactsAll'
id,first_name, last_name, phone
I copied ContactsPart1 structure and added id made it primary key and auto increment.
When I try the following command:
INSERT INTO `ContactsAll` SELECT first_name, last_name, phone FROM `ContactsPart1`
I get:
MySQL said:
#1136 - Column count doesn't match value count at row 1
How do I get the info in to the new table w/ a SQL command and unique id for each record?
I'm using php, but would rather do this through a SQL command. Thank you for your time.
Table 'ContactsPart1':
first_name, last_name, phone
Table 'ContactsPart2':
first_name, last_name, phone
I want it to be:
Table 'ContactsAll'
id,first_name, last_name, phone
I copied ContactsPart1 structure and added id made it primary key and auto increment.
When I try the following command:
INSERT INTO `ContactsAll` SELECT first_name, last_name, phone FROM `ContactsPart1`
I get:
MySQL said:
#1136 - Column count doesn't match value count at row 1
How do I get the info in to the new table w/ a SQL command and unique id for each record?
I'm using php, but would rather do this through a SQL command. Thank you for your time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER