SQLTeam.com | Weblogs | Forums

New in SQL Need Help

Hello, I'm new to SQL and I'm having trouble with an exercise.
The exercise is based on the attached data model.
The question is:
Who (email) has never been to any show that rita@gmail.com has not been to?

What did I do :
SELECT ticket.email, show.id_espetaculo
FROM ticket ticket
JOIN show show
ON ticket.id_espetaculo = show.id_espetaculo
WHERE ticket.email != 'rita@gmail.com'

This shows me emails other than Rita's.
But it doesn't tell me which one of them didn't go to the shows that she didn't go.

one idea

shows that rita did not go to
INTERSECT
shows that the others did not go to

Thanks,
I am going to try :slight_smile:

I don't know how to write the code to show the shows that each viewer hasn't been to

Try this .. hope this helps

SELECT ticket.email, show.id_espetaculo FROM ticket ticket JOIN show show ON ticket.id_espetaculo = show.id_espetaculo WHERE ticket.email = 'rita@gmail.com'
INTERSECT 
SELECT ticket.email, show.id_espetaculo FROM ticket ticket JOIN show show ON ticket.id_espetaculo = show.id_espetaculo WHERE ticket.email != 'rita@gmail.com'

Thank You