I have some bulk data in a text file that I need to import into a MySQL table. The table consists of two fields ..
- ID (integer with auto-increment)
- Name (varchar)
The text file is a large collection of names with one name per line …
(example)
John Doe
Alex Smith
Bob Denver
I know how to import a text file via phpMyAdmin however, as far as I understand, I need to import data that has the same number of fields as the target table. Is there a way to import the data from my text file into one field and have the ID field auto-increment automatically?
Thank you in advance for any help.
Best Answer
Another method I use that does not require reordering a table's fields (assuming the auto-increment field is the first column) is as follows:
Now you will have a file containing each row of your original file preceded by an empty column, which will be converted into the next relevant auto-increment value upon import via phpMyAdmin.