T
Tig
Question : In Oracle SQL I can do a tree query like below. Can I achieve
the same thing using Acesss 2003 SQL (Jet)? What is the easiet way to
achieve this in Access 2003?
I have a table:
StudentID Name Major GPA TutorId
101 Bill CIS 3.45 102
102 Mary CIS 3.1
103 Sue Marketing 2.95 102
104 Tom Finance 3.5 106
105 Alex CIS 2.75 106
106 Sam Marketing 3.25 103
107 Jane Finance 2.9 102
From above:
a.. Bill tutors Alex, Mary and Sue.
b.. Mary tutors Liz and Ed
c.. Sue tutors Petra
The following example prints a tree structure modeled after the tutoring
relationships in the Students table. Starting with Mary's student id (102)
since no one tutors her.
SELECT LPAD(' ',2*(LEVEL-1)) || students.name
As TutorTree
FROM students
START WITH studentid = '102'
CONNECT BY PRIOR studentid = tutorid;
TUTORTREE
--------------------------------------------------------------------------------
Mary
Bill
Sue
Sam
Tom
Alex
Jane
7 rows selected.
From the tree we can see that Mary tutors Bill, Sue and Jane. In turn, Sue
tutors Sam. Finally, Sam tutors both Tom and Alex.
the same thing using Acesss 2003 SQL (Jet)? What is the easiet way to
achieve this in Access 2003?
I have a table:
StudentID Name Major GPA TutorId
101 Bill CIS 3.45 102
102 Mary CIS 3.1
103 Sue Marketing 2.95 102
104 Tom Finance 3.5 106
105 Alex CIS 2.75 106
106 Sam Marketing 3.25 103
107 Jane Finance 2.9 102
From above:
a.. Bill tutors Alex, Mary and Sue.
b.. Mary tutors Liz and Ed
c.. Sue tutors Petra
The following example prints a tree structure modeled after the tutoring
relationships in the Students table. Starting with Mary's student id (102)
since no one tutors her.
SELECT LPAD(' ',2*(LEVEL-1)) || students.name
As TutorTree
FROM students
START WITH studentid = '102'
CONNECT BY PRIOR studentid = tutorid;
TUTORTREE
--------------------------------------------------------------------------------
Mary
Bill
Sue
Sam
Tom
Alex
Jane
7 rows selected.
From the tree we can see that Mary tutors Bill, Sue and Jane. In turn, Sue
tutors Sam. Finally, Sam tutors both Tom and Alex.