Trying to understand, is there any way to Import specific columns from text-file into mysql with matching existing value in the table.
Ex: I have a table, Ref_by and city does not have any values, wanted to load data from txt file. For values id 1 - Ref_by is 'Name1' and city 'Mumbai' & id 2 - Ref_by is 'Name2' and city 'Chennai'
drop table table1;
create table table1 (id int, name varchar(50),Ref_by varchar(50),Dept varchar(50), city varchar (100));
insert into table1 (id,name,Dept) values (1,'a','IT');
insert into table1 (id,name,Dept) values (2,'b','IT');
select * from table1;
If I load: it is going to as next rows, not sure how to match ID column from MYSQL to text files. Is it possible?
LOAD DATA INFILE 'K:/Load/db/table1_columns.txt' INTO TABLE table1 FIELDS TERMINATED BY '|' ENCLOSED BY '' (Ref_by,city);
Needed result:
1 a name1 IT Mumbai
2 b name2 IT Chennai