distal-attribute
distal-attribute
distal-attribute
distal-attribute

Import only selected columns CSV

User, date Message
Written by dafi
7 months ago
Category: Import/Export
4 posts since Wed, 11 Dec 13
I want to only update one column in a table.
The table has an index column.
So my data looks likes this:
123, 8
125, 4
222, 6
333, 1

The table already contains rows with the values 123, 125, etc
Table columns are:
Index, col2, col3 ColX

I want to update ColX. I have tried with dummy columns in my CSV for col2 & col3 but no good because it complains about no default vlaue for col2.

Import CSV needs some more options. How can I write an SQL query to do this? I need access to the CSV data. I guess I could import into a dummy table then write some SQL to do the update. Not sure what this SQL qould look like.

Thanks DG
Written by jfalchMoney, Euro
7 months ago
386 posts since Sat, 17 Oct 09
this is not possible with import csv, options or not. if you want to update only one column, you have to generate an sql file with a line like
UPDATE table SET colX=valX WHERE keyFieldOfRecord=keyvalX;
for each record to be updated.
Written by dafi
7 months ago
4 posts since Wed, 11 Dec 13
In the Import CSV window on HeidiSQL there is a check box against each column name. I would have thought this was for selecting which fields were to be updated, but it doesn't work like that. What is the purpose of these check boxes anbd exactly how do they work?
Can't Heidi generate the SQL statement you gave for me?
Written by jfalchMoney, Euro
7 months ago
386 posts since Sat, 17 Oct 09
the check boxes are used when you have a .csv import record that contains more fields than the table imported to; they select which of the fields are used for import.

heidisql currently cannot generate the UPDATE statements required; you would have to use/write a program, processing your input file, to do this. AWK or PERL would be good candidates for languages to write this program in.
 

Please login to leave a reply, or register at first.