Hi all,
I want to thank whoever posted the address at
intelligententerprise.com/001020/celko1_1.shtml
for Celko's article about sql trees. It's a powerful concept, and I'm
lost already <g>. So I thought it might be an interesting diversion
for the list. The idea is to create a hierarical model based on
nested sets rather than linking to adjacent records. Celco calls it a
"modified preorder tree transversal algorithm". Sure.... Read the
article if you're interested.
My question is more mundane, as there is an sql construct used
that I don't get.
Imagine this table
emp lft rgt
---------- ---------- ----------
Albert 1 12
Bert 2 3
Chuck 4 11
Donna 5 6
Eddie 7 8
Fred 9 10
and these two queries:
1)
sel p2.* from empl p1, empl p2 +
whe p1.lft between p2.lft and p2.rgt and p1.emp = 'fred'
returns
p2.emp p2.lft p2.rgt
---------- ---------- ----------
Albert 1 12
Chuck 4 11
Fred 9 10
2)
sel p2.* from empl p1, empl p2 whe p1.lft between p2.lft and p2.rgt
and p2.emp = 'fred'
returns
p2.emp p2.lft p2.rgt
---------- ---------- ----------
Fred 9 10
They are correct, but I don't get it, as p1 and p2 are the same
table, and the only difference in the queries is [and p1.emp = 'fred']
in one and [and p2.emp = 'fred'] in the other.
Thanks,
Ben Petersen