Skip to content
Advertisement

CSV to MySQl Import

i need to insert csv into mysql database in proper column.

let say csv has header and then data A B C

and Mysql has table with column C A B

i need to know best way to insert csv data to mysql table

Advertisement

Answer

I believe you can use the following syntax for mysql:

So you can build up your query, using the header and the column it falls into, like so (pseudocode):

Regardless of what order the data is in the table, that will insert data into the correct column.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement