Code:
myTable1
(id) name
(1) Tom
(2) Jane
(3) Chris
(4) Judy
(5) Mary
(6) Jack
(7) James
(8) Bill

myTable
(pom) kid
(1) 2
(3) 1
(3) 4
(5) 8
I have 2 tables like the above.
I like to say the tables says like the below.

Jane is a kid of Tom.
Tom and Judy are kids of Chris.
Bill is a kid of Mary.

Chris is the pom(papa or mom) of Tom and Judy.
Mary is the pom of Bill.
Tom is the pom of Jane.

I like to produce who are poms.
The code below produces the result below.
Code:
code
select name
from myTable1
left join myTable on myTable1.id=myTable.pom
where
myTable.pom is not null
group by pom
order by name

result
Chris
Mary
Tom
Tom is the 2nd generation while Chris and Mary are the 1st generation,
because Tom is a kid of Chris.
I like to remove Tom for producing the 1st generation people only.

The following is my target result with myTable1 and myTable above.
Code:
target result

Chris
Mary
How can I get my target result above?


The following is one of my trials, but it causes an error.
Code:
select name
from myTable1
left join myTable on myTable1.id=myTable.pom
left join myTable on myTable1.id=myTable.kid
where
myTable.pom is not null
and
myTable.kid is null
group by pom
order by name