Good Morning,
I am on a SQL learning tour and trying to create a small database with a few queries to gain experience. Two databases where used, Person {id, name, age} and Knows {id, guest1_id → Persons, guest2_id → Persons}
The query should result in a list of names of people that do not know anyone from the database, but can be known by others. Below is the code that I have got so far, but it does not seem to acquire anything.
What is the problem here?
SELECT distinct K.id
FROM Persons P
LEFT JOIN Knows K
ON K.guest1_id = P.id
AND K.guest2_id = P.id
WHERE K.id NOT IN (
SELECT id
FROM Knows )
Thank you!