I have three tables,
- comments: id, user_id, place_id, text
- places: id, name
- users: id, name
I'd like to show a list of all the places with a list of all the users who commented on that place.
McDonalds Jill, Suzy, Bob
Walmart Fred, Joe, Suzy, Larry
Library Joe, Suzy
...
I am trying to use the coalesce
function to achieve this but I am running into trouble. What am I doing wrong?
SELECT places.name, COALESCE(users.name+",")
FROM comments
JOIN places
ON comments.place_id = places.id
WHERE user_id = users.id
GROUP BY places.name
Thanks.