Records which are not a variable

[B]myTable1
(id) name[/B]
(1)  Tom
(2)  Jane
(3)  Chris
(4)  Judy
(5)  Mary
(6)  Jack
(7)  James
(8)  Bill

[B]myTable
(pom) kid[/B]
(1)   2
(3)   1
(3)   4
(5)   8

I have 2 tables like the above.

The code1 below produces the result1 below.

[B]code1[/B]
select  id, name
from myTable1
left join myTable as myPom on myTable1.id=myPom.pom
left join myTable as myKid on myTable1.id = myKid.kid
where
myKid.pom = 3  /* when the variable is 3
order by id

[B]result1[/B]
(1) Tom
(4) Judy 

I like to retrieve all persons in myTable1 except Tom and Judy who are not kids of Chris.
The code2 below is one of my trials for it, however it failed in producing my target result below.

[b]code2[/b]
select id, name
from myTable1
left join myTable as myPom on myTable1.id=myPom.pom
left join myTable as myKid on myTable1.id = myKid.kid
where
myKid.pom <> 3
order by id

[b]result2[/b]
(2) Jane
(8) Bill

[b]target result[/b]
(2)  Jane
(3)  Chris
(5)  Mary
(6)  Jack
(7)  James
(8)  Bill 

come on, joon, i’ve taught you all this stuff before

when you want to find rows in one table where matching rows in another table don’t exist, you use a LEFT OUTER JOIN with an IS NULL check

SELECT myTable1.id
     , myTable1.name
  FROM myTable1
LEFT OUTER
  JOIN myTable as myPom
    ON myPom.pom = myTable1.id
LEFT OUTER
  JOIN myTable as myKid
    ON myKid.kid = myTable1.id
   [B]AND [/B][COLOR="#0000FF"]myKid.pom = 3[/COLOR]
 WHERE [COLOR="#0000FF"]myKid.kid IS NULL [/COLOR]
ORDER
    BY myTable1.id

notice it’s an AND condition in the ON clause