I am trying to use the code seen in this example here:
MySQL load NULL values from CSV data
I am using this code (Which works when I don't use the last three lines)
LOAD DATA LOCAL INFILE 'Myfiles/Products.csv'
INTO TABLE tblProducts
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(product_id, manufacturer, sku, pname, price, @vstock, @vcategory_id, lf_code)
stock = ifnull(@vstock = ''),
category_id = ifnull(@vcategory_id = '');
You should beusing
IFNULL(). It takes two arguments: an expression to return in the normal case, and something else to compare with it, and it returns
NULL if they're equal. You don't write
= between them.
stock = nullif(@vstock, ''), category_id = nullif(@vcategory_id, '');