• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 442
  • Last Modified:

Mysql Query to copy columns between tables

I need to know how to copy the field data in a column from a populated mysql table, to an unpopulated mysql table.

Table1 - populated with rows
Columns - products_id, column_2, column_3 ...

Table2 - an empty table
Columns - products_id, column_A, column_B ...

I would like to mirror the Table1.product_id column over to Table2.product_id column

Is there a mysql query that would allow this to happen?
  • 2
1 Solution
Dan CraciunIT ConsultantCommented:
Try this (untested):
INSERT INTO table2 (products_id) 
SELECT products_id FROM table1

Open in new window

It more or less should work like this: http://dev.mysql.com/doc/refman/5.1/en/insert-select.html

FourMatAuthor Commented:
Well, that was incredibly simple and I feel like an idiot for making it more complicated than it needed to be.  Thanks for the help!
Dan CraciunIT ConsultantCommented:
Glad I could help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now