SQLTeam.com | Weblogs | Forums

How to do JOIN

Hello everyone,
I'm a new user of SQL and I'm trying to get familiar with JOIN functions.
Here's an example of what I'm trying to do for a couple of days, but can't find the right solution. I would love your help.

In the sakila database every film can have multiple categories that it belongs to. Every
film can also have multiple actors that participated in it. We would like to know for each category which actors played in films belonging to that category.
Write a SELECT query that returns one row for each category. The result should have
two columns:

  • Column name should contain the name of the category.
  • Column actors should contain a comma (,) separated list of distinct actor

Thank you very much for your help!


Please provide your sample like following example

declare @colors table(name int, value varchar(50))

insert into @colors

select 1, 'Red' union
select 2, 'Green' union
select 3, 'Blue' union
select 4, 'Yellow' union
select 5, 'White'