This is a discussion on RE: building comma-separated list of strings from subquery within the MySQL General forum forums, part of the MySQL category; --> >I'ld like to accomplish something like: > >set @myvar=concat_ws(",",(SELECT column from table1 order by column; >where ...)) > >or ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| >I'ld like to accomplish something like: > >set @myvar=concat_ws(",",(SELECT column from table1 order by column; >where ...)) > >or > >select concat_ws(",",(SELECT column from table1 order by column where ...)); > >for further usage in sql-scripts I forgot to mention: As I need it in a function, i think i cant use the second version. Does anyone know of a way to build a comma-separated list aka "set" from rows of a table? Any suggestions welcome! TIA P.S. sorry for double-cross-wrong posting this to another thread |
| ||||
| You probably want to look at the group_concat function. It doesn't work as a subselect, but it allows you to group a set of records and "rollup" the different values in the grouping. Christian Hansel wrote: >> I'ld like to accomplish something like: >> >> set @myvar=concat_ws(",",(SELECT column from table1 order by column; >> where ...)) >> >> or >> >> select concat_ws(",",(SELECT column from table1 order by column where ...)); >> >> for further usage in sql-scripts >> > > I forgot to mention: As I need it in a function, i think i cant use the > second version. > > Does anyone know of a way to build a comma-separated list aka "set" from rows > of a table? > > Any suggestions welcome! > > TIA > > > P.S. sorry for double-cross-wrong posting this to another thread > > |