I have a csv file that is formated as follows:
Rank, URL
1, www.google.com
2, www.facebook.com
etc...
I have a table with structure
url, source, date_added
Where each csv file has a different source ID.
I am using the following query to load my data
load data local infile 'this.csv'
into table seeds.seed
fields terminated by ',';
Which doesn't quite do what I want but it's my starting point. What I want to do is select column 2 to be inserted as my URL field, and set the source to 0 for each entry. So I am thinking something like this...
load data local infile 'this.csv'
into table seeds.seed(url, source)
select col1, '0'
fields terminated by ',';
What is the correct notation for col1? And am I missing any other key parts to the query?
LOAD DATA INFILE 'this.csv'
INTO TABLE seed
(col1) SET source = 0;
FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '"'
LINES TERMINATED BY '\r\n';
Have a look into SO answer.
This is the reference