MySQL Import & Replace via CSV

csvexportimportMySQLphpmyadmin

I have a MySQL database table named items with 10,000+ records. Of these records, I would like to export only records where item_isbn IS NULL.

SELECT * FROM Items WHERE item_isbn IS NULL produces a table with 500 records, a sample of the data is below;

+---------+------------+-----------+
| item_id | item_title | item_isbn |
+---------+------------+-----------+
| 1       | Jo         | NULL      |
+---------+------------+-----------+
| 24      | Cars       | NULL      |
+---------+------------+-----------+
| 315     | Fun        | NULL      |
+---------+------------+-----------+
| etc     | etc        | etc       |
+---------+------------+-----------+

I have exported this table as a CSV file, and have populated it with the necessary ISBNs via MS Excel. I'm now ready to re-import the data into the itens table.

How can I re-import these 500 records into the items table, whilst overwriting only the same 500 records, and maintaining the same item_id.

Is there a more efficient way of doing this?

I am using PhpMyAdmin.

Any help appreciated.

Best Answer

Simply delete the rows where item_isbn IS NULL and then import the updated CSV file.

While importing, you can disable auto_increment as well in case you're concerned about messing item_id identity.