Unix Technical Forum

RE: building comma-separated list of strings from subquery

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:37 AM
Christian Hansel
 
Posts: n/a
Default RE: building comma-separated list of strings from subquery

>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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:37 AM
Brent Baisley
 
Posts: n/a
Default Re: building comma-separated list of strings from subquery

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
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:11 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com