Đinh Carabus
Đinh Carabus

Reputation: 3494

Import SQL File into existing DB-Table (phpmyadmin)

I have an SQL-File defining a table with 2 columns - product-id and product-reference. I need to import that file into an existing table that has the same structure (plus some extra columns), where product-id corresponds to the product-id from the backup file. Is there a simple way to do that via phpmyadmin?

Upvotes: 1

Views: 2037

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270773

One approach is to use load data infile (see here) with the set option to assign column values. Columns that are not being set will be given their default values, which is typically NULL.

Personally, I would load the data into a staging table with two columns and then insert the data from the staging table into the final table. This makes it easier to validate the data before putting it into the "real" table.

Upvotes: 2

Related Questions