New Line character \n in SQLite concatenate

newline, sqlite

Solution

SQL has no backslash escapes.

You can generate a newline in a string by writing it directly in the query:

SELECT [Field1] || '
' || [Field2] FROM MyTable

or use a blob literal:

SELECT [Field1] || x'0a' || [Field2] FROM MyTable

or use the char function:

SELECT [Field1] || char(10) || [Field2] FROM MyTable

Problem

I know that, in some Programming language, if you do something like: ``` 'This is on first line \n This is on second line' ``` Then it will display properly like this: ``` This is on first line This is on second line ``` When I concatenate a string in a SQLite database ``` SELECT *, [FIELD1] || '\n' || [FIELD2] from TABLE ``` (where [FIELD1] = This is on first line [FIELD2] = This is on second line) it displays as such: ``` This is on first line \n This is on second line ``` Is there a reason that it isn't displaying the \n characters properly?

Original source