select query into list on one column
10,441
Use GROUP_CONCAT():
SELECT GROUP_CONCAT(id) AS idList FROM tableA
Author by
majidarif
I would love to change the world, but they won't give me the source code. Linkedin | Github
Updated on August 01, 2022Comments
-
majidarif almost 2 years
I am trying to select all id into one column and delimit it with a comma
,
My DATA column:
+---+--------+--------------+ |id |somedata|someother data| +---+--------+--------------+ |1 |data1 |other1 | +---+--------+--------------+ |2 |data2 |other2 | +---+--------+--------------+ |3 |data3 |other3 | +---+--------+--------------+
The result I am trying to make:
+-------+ |id list| +-------+ |1, 2, 3| +-------+
The result should be a list of ID's in 1 column named 'id list'.
The question is, is this possible? and how? I tried searching for the keywords
sql query select into list
and other keywords but with no luck.
But this query is on a nested select.