Import just certain colums of the table

[expired user #6593]'s profile image [expired user #6593] posted 12 years ago in Import/Export Permalink
I have a datatable and i just want to update (not create new) the existing cells, there are 10 columns in the table, but i only want to import 3, is there a way to make it so that only the 3 columns are updated and the other 10 will be as they are?

Ps. Great program
ansgar's profile image ansgar posted 12 years ago Permalink
Where are you, in the query editor or in the "Import textfile" dialog?
[expired user #6593]'s profile image [expired user #6593] posted 12 years ago Permalink
I have selected the database->selected the table i want to import to->Data Leaf then Tools->Import CSV-file.
ansgar's profile image ansgar posted 12 years ago Permalink
Ah, so it is the import dialog. Well, you have to create an appropriate CSV file with your wanted columns, and then tell HeidiSQL via checkboxes which columns exist in that file.
[expired user #6593]'s profile image [expired user #6593] posted 12 years ago Permalink
I did that but it cleared all the other fields also.

jfalch's profile image jfalch posted 12 years ago Permalink
to be certain: how many columns (separated bywinkdoes your .csv file contain ?
[expired user #6593]'s profile image [expired user #6593] posted 12 years ago Permalink
3 columns. products_id, products_quantity, products_model
[expired user #6593]'s profile image [expired user #6593] posted 12 years ago Permalink
It clears out the image/price etc. columns also
ansgar's profile image ansgar posted 12 years ago Permalink
Yes, if you uncheck a column in that dialog, HeidiSQL does not include that one in the LOAD DATA command.

I have a gutt feeling you are expecting an update of existing rows in your table, which no importer can do for you. The LOAD DATA command always creates new rows.
[expired user #6593]'s profile image [expired user #6593] posted 12 years ago Permalink
yes i'm trying to update the existing tables, i guess i have to update the whole table in the same time?
jfalch's profile image jfalch posted 12 years ago Permalink
a simple solution would probably be: let what/whoever generates the above mentioned .csv file, generate an .sql file instead.
Ie where you noww have a line of e.g.

9;5;XXX

in your .csv file, instead generate a line containing

UPDATE products SET products_quantity=5,products_model="XXX" WHERE products_id=9;

when this has been done for all changes, load the generated .sql file into a heidisql query tab, and execute it there.
[expired user #6593]'s profile image [expired user #6593] posted 12 years ago Permalink
Thanx for the help you guys, i got it working smile

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