Re: How to format strings - Mailing list pgsql-general

From Warren Vanichuk
Subject Re: How to format strings
Date
Msg-id Pine.LNX.4.21.0011082151430.12417-100000@urd.street-light.com
Whole thread Raw
In response to How to format strings  (Ian Willis <Ian.Willis@ento.csiro.au>)
List pgsql-general
> Some time ago I saw the someone give an example of how to combine a
> query result with test using sql.
> What i have is a table with f_name varchar l_name varchar and I want the
> result to say f_name.l_name@mydomain.com
> Is this possible I will redirect the output to a textfile using the \o
> option.

The only way I could come up with to do this is :

test=> \d test
Table    = test
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                | Length|
+----------------------------------+----------------------------------+-------+
| text1                            | varchar()                        |   255 |
| text2                            | varchar()                        |   255 |
+----------------------------------+----------------------------------+-------+

test=> select textcat( textcat( textcat( text1, '.' ), text2 ), '@domain.com' ) as result from test;
result
------------------
foo.bar@domain.com
bar.vaz@domain.com
bar.foo@domain.com
(3 rows)

Perhaps somebody has a better way? :)

Hope this helps! :)

Sincerely, Warren


pgsql-general by date:

Previous
From: Ian Willis
Date:
Subject: How to format strings
Next
From: Charles Curley
Date:
Subject: Re: [NOVICE] Re: VACUUM AND VACUUM ANALYSE