Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One solution is to use the MySQL function "CHAR()" to represent the "\n" as a character instead of a line break. For example, if you want to store the string "Hello\nWorld" with the line break intact, you can use the following SQL command:

INSERT INTO tablename (columnname) VALUES ('Hello' + CHAR(10) + 'World');

The CHAR(10) function represents the line break as a character and will preserve it in the database. When retrieving the data, you can use the MySQL function "REPLACE()" to replace the character back into a line break, if needed.