Paul Oyster
Paul Oyster

Reputation: 1248

How to avoid double backslash in MySQL's SELECT INTO OUTFILE

In MySQL, the following:

SELECT '\\' INTO OUTFILE 'c:/temp/backslash.dump';

writes two backslashes to the file, which makes sense.

Trying to dump a single backslash, I changed SQL_MODE, like that:

SET SESSION SQL_MODE='NO_BACKSLASH_ESCAPES';
SELECT '\' INTO OUTFILE 'c:/temp/backslash.dump';

but got two backslashes again.

Is there a way to dump a single backslash?

Upvotes: 1

Views: 2672

Answers (1)

Gal Cohen
Gal Cohen

Reputation:

Do this:

SELECT '\\' INTO OUTFILE 'c:/temp/backslash.dump' FIELDS ESCAPED BY '|';

Upvotes: 1

Related Questions