string concatenation?

Started by Esa Pikkarainenover 25 years ago4 messagesgeneral
Jump to latest
#1Esa Pikkarainen
epikkara@ktk.oulu.fi

I could not find explicite answer in docs and before massive testing
I would like to as is this at all possible:

I want to get string value which is a comma separated combination of
two integers. I want to get these both values from one subquery. In
Access I could do it this way:

SELECT other-fields,
(SELECT [value1] & ',' & [value2] AS value1-2
FROM this-table WHERE id = 1)
as value1-2
FROM other-tables
;

If value1 = 1 and value2 = 2 then the query result of value1-2 = 1,2

If I remember right there was some "concat" function in Mysql. Access
uses "&" from Visual Basic. I don't think it will work with
Postgresql.

Thanks
Esa Pikkarainen

#2Gregory Wood
gregw@com-stock.com
In reply to: Esa Pikkarainen (#1)
Re: string concatenation?

Double pipe will allow you to concatenate strings. For example:

SELECT FirstName||' '||LastName AS FullName FROM Employee;

Or as your example:

SELECT other-fields,
(SELECT value1||','||value2 AS value1-2
FROM this-table WHERE id = 1)
as value1-2
FROM other-tables

Greg

----- Original Message -----
From: "Esa Pikkarainen" <epikkara@ktk.oulu.fi>
To: <pgsql-general@postgresql.org>
Sent: Monday, January 08, 2001 7:35 AM
Subject: string concatenation?

Show quoted text

I could not find explicite answer in docs and before massive testing
I would like to as is this at all possible:

I want to get string value which is a comma separated combination of
two integers. I want to get these both values from one subquery. In
Access I could do it this way:

SELECT other-fields,
(SELECT [value1] & ',' & [value2] AS value1-2
FROM this-table WHERE id = 1)
as value1-2
FROM other-tables
;

If value1 = 1 and value2 = 2 then the query result of value1-2 = 1,2

If I remember right there was some "concat" function in Mysql. Access
uses "&" from Visual Basic. I don't think it will work with
Postgresql.

Thanks
Esa Pikkarainen

#3Esa Pikkarainen
epikkara@ktk.oulu.fi
In reply to: Gregory Wood (#2)
Re: string concatenation?

Fine,
Thank you very much.
Esa

Gregory Wood wrote (8 Jan 01,):

Show quoted text

Double pipe will allow you to concatenate strings. For example:

SELECT FirstName||' '||LastName AS FullName FROM Employee;

Or as your example:

SELECT other-fields,
(SELECT value1||','||value2 AS value1-2
FROM this-table WHERE id = 1)
as value1-2
FROM other-tables

Greg

----- Original Message -----
From: "Esa Pikkarainen" <epikkara@ktk.oulu.fi>
To: <pgsql-general@postgresql.org>
Sent: Monday, January 08, 2001 7:35 AM
Subject: string concatenation?

I could not find explicite answer in docs and before massive testing
I would like to as is this at all possible:

I want to get string value which is a comma separated combination of
two integers. I want to get these both values from one subquery. In
Access I could do it this way:

SELECT other-fields,
(SELECT [value1] & ',' & [value2] AS value1-2
FROM this-table WHERE id = 1)
as value1-2
FROM other-tables
;

If value1 = 1 and value2 = 2 then the query result of value1-2 = 1,2

If I remember right there was some "concat" function in Mysql. Access
uses "&" from Visual Basic. I don't think it will work with
Postgresql.

Thanks
Esa Pikkarainen

#4José Soares
jose@sferacarta.com
In reply to: Esa Pikkarainen (#1)
Re: string concatenation?

Esa Pikkarainen wrote:

I could not find explicite answer in docs and before massive testing
I would like to as is this at all possible:

I want to get string value which is a comma separated combination of
two integers. I want to get these both values from one subquery. In
Access I could do it this way:

SELECT other-fields,
(SELECT [value1] & ',' & [value2] AS value1-2
FROM this-table WHERE id = 1)
as value1-2
FROM other-tables
;

PostgreSQL uses the vertical bar '|' to concatenate strings this is
Standard SQL.

SELECT other-fields,
(SELECT value1 | ',' | value2
FROM this-table WHERE id = 1
) as value12
FROM other-tables;

Show quoted text

If value1 = 1 and value2 = 2 then the query result of value1-2 = 1,2

If I remember right there was some "concat" function in Mysql. Access
uses "&" from Visual Basic. I don't think it will work with
Postgresql.

Thanks
Esa Pikkarainen