Create an Account
username: password:
 
  MemeStreams Logo

MemeStreams Discussion

search


This page contains all of the posts and discussion on MemeStreams referencing the following web page: PostgreSQL & PHP Tutorials - Group Concat - Simple Example. You can find discussions on MemeStreams as you surf the web, even if you aren't a MemeStreams member, using the Threads Bookmarklet.

PostgreSQL & PHP Tutorials - Group Concat - Simple Example
by Lost at 3:48 am EDT, Jun 4, 2008

The subquery has to do a join based on the outside id (which happens to be a self join - ie back to the same database table), then we group & order the results together.

select id,
count(outside_example.*),
array_to_string (
array(
select val from example inside WHERE inside.id=outside_example.id
), ','
)
FROM example outside_example
GROUP BY outside_example.id
ORDER BY outside_example.id
;


 
 
Powered By Industrial Memetics