Hi! I'm doing an exercise in SQL.
The exercise is based on the following data model:
The question is:
Which pairs of people (emails) always went to the shows together?
The code I wrote was the following:
SELECT DISTINCT bilhete.email, bilhete_1.email, espetaculo.id_espetaculo
FROM bilhete bilhete
JOIN espetaculo espetaculo
ON bilhete.id_espetaculo = espetaculo.id_espetaculo
JOIN bilhete bilhete_1
ON bilhete.email = bilhete_1.email
Now I need to filter the result for emails that have the same Id_espetaculo.
How do I do?