我使用以下指令在MySQL表中加载csv文件:
LOAD DATA INFILE 'myfile.csv'
INTO TABLE MYTABLE
FIELDS TERMINATED BY ";"
LINES TERMINATED BY "\r\n";
我想写一下null而不是空字段:
LOAD DATA INFILE 'myfile.csv'
INTO TABLE MYTABLE
FIELDS TERMINATED BY ";"
LINES TERMINATED BY "\r\n"
(field1, @field2, field3)
SET
field2 = NULLIF(@field2, '');
效果很好,但是当我使用NULLIF时,即使空白字段也被置为NULL。
我怎么能说只有空字段变为NULL但空白字段保持不变?