Reputation: 771
I am trying to enter data into mysql table Fruitbox .But while entering data I am getting error Fruitpdf cannot be null. I created fruitbox table as follows:
Fruitname(varchar(100), Fruitpdf(blob), Fruitprice(int)
Fruitpdf column contains pdf files of fruit. My file mango.pdf in desktop is size of 190 KB.
I wrote following query but getting error "Fruitpdf cannot be null" while executing sql statement.
INSERT INTO Fruitbox (Fruitname, Fruitpdf, Fruitprice) VALUES ('Mango', LOAD_FILE('C:\Users\Tom\Desktop\mango.pdf'), '100');
Where I am wrong ? Any help is much appreciated. Thanking you
Upvotes: 0
Views: 1007
Reputation: 848
MySQL treats a backslash in a string as an escape character. You need to use a double backslash :
LOAD_FILE('C:\\Users\\Tom\\Desktop\\mango.pdf')
See https://dev.mysql.com/doc/refman/8.0/en/string-literals.html
Edit : If it still doesn't work :
Upvotes: 1