Create an Account
username: password:
 
  MemeStreams Logo

PostgreSQL & PHP Tutorials - Group Concat - Simple Example

search

Lost
Picture of Lost
My Blog
My Profile
My Audience
My Sources
Send Me a Message

sponsored links

Lost's topics
Arts
Business
Games
Health and Wellness
Home and Garden
Miscellaneous
Current Events
Recreation
Local Information
Science
Society
Sports
Technology

support us

Get MemeStreams Stuff!


 
PostgreSQL & PHP Tutorials - Group Concat - Simple Example
Topic: Technology 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
;

PostgreSQL & PHP Tutorials - Group Concat - Simple Example



 
 
Powered By Industrial Memetics
RSS2.0