On Thursday, July 9, 2015, JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> wrote:
> I have a query like the following:
>
> SELECT fld1 || fld2
>
> I need to insert a carriage return (\r) and a line feed (\n) after each
> field. How can I do this?
>
> I tried
> SELECT fld1 || \r\n || fld2 || \r\n
> and also
> SELECT fld1 || '\r\n' || fld2 || '\r\n'
>
> without success.
>
> I will very much appreciate your feedback.
>
SELECT fld1 || E'\r\n' || fld2
The E tells Postgresql to interpret backslash escapes within the string.
David J.