By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,179 Members | 970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,179 IT Pros & Developers. It's quick & easy.

Concatenation in SELECT

P: n/a
Hi,
is it possible to concatenate two rows (same or different data type)
into one.
like First Name, Last Name or ZIP City etc.

Thanks
Alex

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 21 Nov 2003 20:22:17 +0900, Alex <al**@meerkatsoft.com> wrote:
Hi,
is it possible to concatenate two rows (same or different data type)
into one.
like First Name, Last Name or ZIP City etc.


If you meant to concatenate two *columns*, it goes like

SELECT firstname || ' ' || lastname AS fullname FROM ...

or for nullable columns

SELECT coalasce(firstname || ' ', '') ||
coalesce(lastname, '') AS ...

This should work for non-text datatypes as well, because most, if not
all, datatypes have implicit casts to text.

Servus
Manfred

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.