Results 1 to 6 of 6
Thread: 1st generation people only
Jun 11, 2012, 04:54 #1
- Join Date
- Apr 2003
- daejeon, South Korea
- 1 Post(s)
- 0 Thread(s)
1st generation people onlyCode:
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 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 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
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.
target result Chris Mary
The following is one of my trials, but it causes an error.
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