How to format strings

Started by Willis, Ian (Ento, Canberra)over 25 years ago2 messagesgeneral
Jump to latest
#1Willis, Ian (Ento, Canberra)
Ian.Willis@ento.csiro.au

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

#2Warren Vanichuk
pyber@street-light.com
In reply to: Willis, Ian (Ento, Canberra) (#1)
Re: How to format strings

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