Обсуждение: INSERTING "NEW LINES" IN A SELECT STATEMENT

Поиск
Список
Период
Сортировка

INSERTING "NEW LINES" IN A SELECT STATEMENT

От
JORGE MALDONADO
Дата:
I have a query like this:
 
SELECT field1 || field2 AS finalfield FROM table1
 
Is it possible to insert a new line between "field1" and "field2" (carriage return, line feed or something) so when "finalfield" is displayed it is shown in 2 lines?
 
My web application actually displays one line as follows depending on the internet browser:
1. The line displayed is "cut" so part of the information is not seen.
2. All of the information is displayed but the horizontal scrolling bar appears to "move the screen" to the right and read the complete information.
 
With respect,
Jorge Maldonado

Re: INSERTING "NEW LINES" IN A SELECT STATEMENT

От
Ognjen Blagojevic
Дата:
JORGE MALDONADO wrote:
> I have a query like this:
>
> SELECT field1 || field2 AS finalfield FROM table1
>
> Is it possible to insert a new line between "field1" and "field2"
> (carriage return, line feed or something) so when "finalfield" is
> displayed it is shown in 2 lines?

It is possible to insert escape characters like \n, \r or \f. For
details see this link:

   http://www.postgresql.org/docs/8.3/static/sql-syntax-lexical.html


> My web application actually displays one line as follows depending on
> the internet browser:
> 1. The line displayed is "cut" so part of the information is not seen.
> 2. All of the information is displayed but the horizontal scrolling bar
> appears to "move the screen" to the right and read the complete information.

If you plan to output the results into HTML you might want to insert
"<br>" instead of \n... or to handle the problem using CSS.

Regards,
Ognjen