Game(p1, p2, pointsp1, pointsp2, ),
Participant(name, club, age)
FK Game(p1) references Participant(name),
FK Game(p2) references participant(name)
This is my relational schema and I am trying to return the list of names of participants who participated in the game but have not won...
So, I have
- gathered all names,
- removed who won from all names through not exists
- removed all the draw names
BUT I AM UNABLE TO ELIMINATE THE PEOPLE WHO HAVE NOT PARTICIPATED IN THE GAME BUT ARE STILL IN THE name COLUMN OF PARTICIPANTS TABLE.
This part of my code is not working
{
SELECT name
FROM Participant
JOIN Game
WHERE Participant.name!=Game.p1
OR Participant.name!=Game.p2
}
This is my complete code:
SELECT name
FROM Participant P
WHERE name NOT IN (
SELECT DISTINCT p1
FROM Game G
WHERE pointsp1 > pointsp2
UNION ALL
SELECT DISTINCT p2
FROM Game G
WHERE pointsp1 < pointsp2
UNION ALL
SELECT ender
FROM Game G
WHERE pointsp1 = pointsp2
UNION ALL
SELECT starter
FROM Game G
WHERE pointsp1 = pointsp2
UNION
SELECT name
FROM Participant
JOIN Game
WHERE Participant.name!=Game.p1
OR Participant.name!=Game.p2
)