I am importing data from a CSV file into a MySQL table. When basic queries such as
select * from Mapping where floor = 'L1';
were not working, after lot of struggle I found that it is because of the white spaces and query
select * from Mapping where floor like '%L1%';
was giving me the expected results.
This is how I am loading my CSV to a table:
LOAD DATA LOCAL INFILE "../.../mapping.csv" INTO TABLE db.Mapping
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES
I am not sure where the white spaces are coming from? Am I loading my CSV in a correct manner? Is there something that I can do to avoid white spaces?
Update
I have tried as per the answers,
Query OK, 0 rows affected (0.00 sec)
Rows matched: 49 Changed: 0 Warnings: 0
It says no rows affected.
select * from Mapping where floor = 'L1';
is still not working, but
select * from Mapping where floor like '%L1%';
is giving the expected results.
Data of CSV file:
V,M,Floor
1,15,L1
2,14,L1
3,14,L1
4,16,L1
5,16,L1
6,6,L1
7,14,L1
8,13,L1
9,12,L1
10,11,L1
11,16,L1