ive been trying to find someone with similar problem but without luck so im opening a new questions.
I have a simple select statement that generates a text file.
SELECT '1','2'
UNION all
SELECT Column1, Column2
INTO OUTFILE '/path/file.txt'
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n\r' **<-- THE ISSUE**
FROM db.table limit 0,100;
The output is fine except one thing. It keeps adding \N to line break. I dont want any character to be the line break i want the line break to be a actual line break.
As it is now:
1 2
Example Example\N
Example Example\N
How i want it to be
1 2
Example Example
Example Example
Ive tried so many combinations, even if i skip the entire LINES TERMINATED BY '', it still adds \N to the output file. If i use the workbench export button, it works excellent, but this is a part of a stored procedure so that is not a solution for me.
It is expecting a BIN_NUM, HEX_NUM or TEXT_STRING.
How can i apply a HEX_NUM to the statement? The mysql version is 5.6
Thanks in advance
It turns out the \N
was filled in when the field was null. I just simply added a IFNULL(Column,'')
to the columns initial select and now my problem is gone!