LOAD DATA LOCAL INFILE Vs Backslash

Hi

I'm using LOAD DATA LOCAL INFILE to import a comma separated file. However the file contains \(backslashes). Are there any way to get mysql not to escape thoses
sduItServiceAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

todd_farmerCommented:
Hi sduItService,

LOAD DATA INFILE ... FIELDS ESCAPED BY '';  

Cheers!
sduItServiceAuthor Commented:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'FIELD
S ESCAPED BY ''
todd_farmerCommented:
What are you using as the actual command?  You will need to replace the ... with your existing parameters.  If you want to give me the full SQL command you were using initially, I can alter it for you.  I just don't know the other elements (file name, etc.) you are using.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

sduItServiceAuthor Commented:
use pcounter;
drop table log;
CREATE TABLE log (Username VARCHAR(15), Filename VARCHAR(100), Printer VARCHAR(50), Dato VARCHAR(15),tid VARCHAR(15), Workstation VARCHAR(20), spacer1 VARCHAR(20), spacer2 VARCHAR(20), Papertype VARCHAR(15), Parameters VARCHAR(50), Size VARCHAR(10), Pages VARCHAR(10), Cost VARCHAR(10), Balance VARCHAR(10));
LOAD DATA LOCAL INFILE 'C:\\temp\\pcounter.log'
INTO TABLE log
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
FIELDS ESCAPED BY ''
(Username, Filename, Printer, Dato, tid, Workstation, spacer1, spacer2, Papertype, Parameters, Size, Pages, Cost, Balance);
todd_farmerCommented:
Try this:

LOAD DATA LOCAL INFILE 'C:\\temp\\pcounter.log'
INTO TABLE log
FIELDS TERMINATED BY ','
ESCAPED BY ''
LINES TERMINATED BY '\n'
(Username, Filename, Printer, Dato, tid, Workstation, spacer1, spacer2, Papertype, Parameters, Size, Pages, Cost, Balance);

Also note that you don't have to drop and recreate the table unless you are changing the table format - you can replace the DROP and CREATE statements with the following:

TRUNCATE log;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sduItServiceAuthor Commented:
thx mate. It did the the job.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.