Search Postgresql Archives

Re: looking for alternative to MySQL's GROUP_CONCAT function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 21, 2005 at 11:58:07AM -0700, x3v0-pgsql@xxxxxxxxx wrote:
> Hi all, 
> 
> I'm looking into PostgreSQL. Coming from a MySQL background, I have
> made heavy use of its very useful GROUP_CONCAT function. You can
> read about the function here:
> 
> http://dev.mysql.com/doc/refman/4.1/en/group-by-functions.html
> 
> Is there a PostgreSQL alternative to GROUP_CONCAT?

There's a more flexible one :)

Use the array_accum() aggregate as described here

http://www.postgresql.org/docs/current/static/xaggr.html

and wrap it with array_to_string()

http://www.postgresql.org/docs/current/static/functions-array.html

to get a nice, flexible system.  You can make a static one if you
like.  One thing about this approach is that you then have to exclude
NULLs from your search because PostgreSQL arrays can't yet hold NULLs.

Cheers,
D
-- 
David Fetter david@xxxxxxxxxx http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux