Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register


1
(click on this box to dismiss)

How do I concatenate multiple rows into a single value?

I want to get the contents of the following table as a single comma separated value:

NAMES

-----

John

Paul

Marry

Steve

And the result should be 'John, Paul, Marry, Steve'

link comment (0)
asked 3 years ago
eusto
204
64 Answers
1
CREATE TABLE t(name VARCHAR(255));
INSERT INTO t VALUES ('John'),('Paul'),('Marry'),('Steve');

SELECT GROUP_CONCAT(name) as name FROM t;

See also http://www.cubrid.org/concat_different_row_columns which uses hierarchical functions like SYS_CONNECT_BY_PATH.

link comment (1)
answered 3 years ago
dba
558
tagged




You are either using a very old browser or a browser that is not supported.
In order to browse cubrid.org you need to have one of the following browsers:



Internet Explorer: Mozilla Firefox: Google Chrome: