I have a very large table and would need to split into lots of tables.

The large table has lots of fields of which `Model.ID` gives a number of the product and this is repeated lots of times with other fields used in the row.

I need to create lots of new tables based on the Model ID field and its associated fields in that row need to be kept together. So if `Model.ID` = 1614 then a new table will be created and inserted into that will be all the rows that have that.

Obviously i need code that does them all and the `model.ID` dont go in order and are pretty random.

Could anybody help please, as this is way above what i can do php wise.

6 Years
Discussion Span
Last Post by mpc123

You can use a query like

INSERT INTO new_table (modelid, column2, column3) SELECT modelid, column2, column3 FROM main_table WHERE modelid = 1614

You can get the unique model id's

SELECT DISTINCT modelid FROM main_table

Hope this will get you started.

Edited by pritaeas: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.