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

Import just certain colums of the table

x808sx posted 2 years ago in Import/Export
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 posted 2 years ago
Where are you, in the query editor or in the "Import textfile" dialog?
x808sx posted 2 years ago
I have selected the database->selected the table i want to import to->Data Leaf then Tools->Import CSV-file.
ansgar posted 2 years ago
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.
x808sx posted 2 years ago
I did that but it cleared all the other fields also.

jfalch posted 2 years ago
to be certain: how many columns (separated bywinkdoes your .csv file contain ?
x808sx posted 2 years ago
3 columns. products_id, products_quantity, products_model
x808sx posted 2 years ago
It clears out the image/price etc. columns also
ansgar posted 2 years ago
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.
x808sx posted 2 years ago
yes i'm trying to update the existing tables, i guess i have to update the whole table in the same time?

jfalch posted 2 years ago
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.
x808sx posted 2 years ago
Thanx for the help you guys, i got it working smile

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