Jump to content

Recommended Posts

Posted

Evening All,

 

Just a random question, do you think that there is a way to have a table in MySQL with all the information in, and then I can have it copy the information from the table to another table?

 

Sounds random but I want to make a kinda reference table with the data and then copy it to several other tables.

 

Thanks in anticipation.

 

Stuart

Posted

Yes, this is possible.

 

The basic syntax for a query to do this is as follows:

 

INSERT INTO `table_two` (col_a, col_b, col_c) SELECT `col_1`, `col_2`, `col_3` FROM `table_one`;

 

The values from table_one in the col_1, col_2, and col_3 columns will be inserted into the col_a, col_b, and col_c columns of table two.

 

It can get more complicated depending on which rows you want to copy, or if you want some different values, but that's the general idea.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...