MySQL load csv into table by matching column titles

Caporegime
Joined
13 Jan 2010
Posts
32,750
Location
Llaneirwg
This is no doubt dead simple

I have a mysql table with column headers such as

Id, house, water

And a csv with line 1 headers such as

Id, waterlevel, house

How can I get the database table to match up using code..
Is it (along with the other load in file bits)

(@Id, @Water level, @House)

Set
Id = @Id
House = @House
Water = @waterlevel


I really would like to use the column id string (line 1 in csv) as the id rather than column1 as it means I avoid having to work out position in the csv to import

This is my first time populating a table.
 
Last edited:
Back
Top Bottom