Thread: How to format strings

How to format strings

From
Ian Willis
Date:
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.
Thanks in advance for any help
--
Ian Willis

Re: How to format strings

From
Warren Vanichuk
Date:
> 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