0

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)
Set 
stock = ifnull(@vstock = ''),
category_id = ifnull(@vcategory_id = '');

However, I keep getting the Error Code 1582: "Incorrect parameter count in the native function call 'ifnull' " Can someone explain what is going wrong?

2
  • ifnull(@vcategory_id,'') Commented Aug 18, 2016 at 1:56
  • OMG LOL I just spent an hour trying to figure that out Commented Aug 18, 2016 at 1:56

1 Answer 1

1

You should beusing NULLIF(), not 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, '');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.