silverkid silverkid - 6 days ago 5
Java Question

Why do I get \N when executing INTO OUTFILE query?

I am connecting to a MySQL database using Java. I am executing this query:

String query =
"SELECT * FROM TT2 " +
"INNER JOIN " +
"`Language Pref` " +
"ON tt2.msisdn = `language pref`.MDN " +
"INTO OUTFILE 'c:/test12226.csv' " +
"FIELDS TERMINATED BY ',' " +
"ENCLOSED BY '\"' " +
"LINES TERMINATED BY '\n'";


I am executing this query using executeQuery(query).

The CSV file generated is perfect except for the last column. In the original table called
Language Pref
the last column had some null or empty cells. In the CSV file, wherever there were these null cells in the original table language pref, I am getting "\N" instead of the null cells as should be.

How can I correct this?

Answer

Well, ,\n at the end of a line represents a null-value in the last column. So everything is fine.

Comments