Add an ID to a Table w/ Auto Increment

Posted on 2007-10-10
Last Modified: 2013-12-13
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.
Question by:smoothcat11
    LVL 142

    Accepted Solution

    INSERT INTO `ContactsAll` (first_name, last_name, phone) SELECT first_name, last_name, phone FROM `ContactsPart1`

    Author Comment

    YOU ARE AWESOME!!!  You just saved me so much time!  Thank you...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now