开发者

Combining result sets into array in SQL query

Let's say i have this table

Col-A     Col B 
  1         2
  1         3
  1         5
  2         1
  2     开发者_JAVA百科    2
  2         8

And i want a query to return a result set built out of Col-A & an array of all Col-B value.

Meaning a select that will return for this specific table:

Record1: 1,[2,3,5]

Record2: 2,[1,2,8]

Is this achievable?

Thanks.


Depending on your DBMS:

Oracle: SELECT col_a, WMSYS.WM_CONCAT(col_b) FROM my_table GROUP BY col_a;

SQLite: SELECT col_a, group_concat(col_b, ',') FROM my_table GROUP BY col_a;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜