T
Ted Allen
Hi,
I believe that your problem stems from the fact that you
want to use your table to represent two different
recordsets being joined, but you haven't defined it that
way. I usually work in the design grid of Access rather
than SQL, so I'll start by describing how to do it
there.
In the design grid, I would usually insert the same table
twice, and Access would give the second instance an alias
(it would add _1 to the name). Then, I would define the
relationship between the two (in your case Dept Reports
To would link to Dept ID). From then on, I would refer
to the fields from one table or another using the
appropriate table name before the field names.
Listed below is the SQL text from a query using this type
of alias. This query joins the table tMaster with two
instances of the table tzlookupOffices.
SELECT tMaster.ID, tMaster.[Project Title],
tzlookupOffices.[Office Name] AS [Design Office],
tzlookupOffices_1.[Office Name] AS [CM Office]
FROM (tzlookupOffices RIGHT JOIN tMaster ON
tzlookupOffices.[Office ID] = tMaster.[Des Dist_ID]) LEFT
JOIN tzlookupOffices AS tzlookupOffices_1 ON tMaster.[CM
Dist_ID] = tzlookupOffices_1.[Office ID];
In your case, you would be joining your two instances of
the Dept table directly, but hopefully this will give you
some ideas.
Hope that helps.
-Ted
can be empty since the top departments don't report to
anyone (for the purpose of this application, anyway)
tbl_department.Dept_name from tbl_Department where
tbl_department.dept_id = DEPT_REPORTSTO) AS ReportsTo
I believe that your problem stems from the fact that you
want to use your table to represent two different
recordsets being joined, but you haven't defined it that
way. I usually work in the design grid of Access rather
than SQL, so I'll start by describing how to do it
there.
In the design grid, I would usually insert the same table
twice, and Access would give the second instance an alias
(it would add _1 to the name). Then, I would define the
relationship between the two (in your case Dept Reports
To would link to Dept ID). From then on, I would refer
to the fields from one table or another using the
appropriate table name before the field names.
Listed below is the SQL text from a query using this type
of alias. This query joins the table tMaster with two
instances of the table tzlookupOffices.
SELECT tMaster.ID, tMaster.[Project Title],
tzlookupOffices.[Office Name] AS [Design Office],
tzlookupOffices_1.[Office Name] AS [CM Office]
FROM (tzlookupOffices RIGHT JOIN tMaster ON
tzlookupOffices.[Office ID] = tMaster.[Des Dist_ID]) LEFT
JOIN tzlookupOffices AS tzlookupOffices_1 ON tMaster.[CM
Dist_ID] = tzlookupOffices_1.[Office ID];
In your case, you would be joining your two instances of
the Dept table directly, but hopefully this will give you
some ideas.
Hope that helps.
-Ted
department that this department reports to), this field-----Original Message-----
I have a department table:
Dept_id (primary key, id number for each department)
Dept_name (descriptive name)
Dept_manager (foreign key to emp_id in employee table)
Dept_reportsto (foreign key to department table, is the
can be empty since the top departments don't report to
anyone (for the purpose of this application, anyway)
the manager is and which department they report to.I'm trying to do a query that lists each department, who
tbl_Department.DEPT_MANAGER, (selectThis is what I have:
SELECT tbl_Department.DEPT_ID, tbl_Department.DEPT_NAME,
tbl_department.Dept_name from tbl_Department where
tbl_department.dept_id = DEPT_REPORTSTO) AS ReportsTo