How to develope query using other queries?

nrmarthi

Registered User.
Local time
Yesterday, 17:08
Joined
Feb 13, 2006
Messages
47
I had prepared three queries

SELECT DepartmentID, DepartmentName FROM Departments UNION Select Null as AllChoice , "All Departments" as Bogus From Departments
ORDER BY DepartmentID; --- From Departments table

SELECT DepartmentID, EmployeeName
FROM Employees
UNION Select Null as AllChoice , "All Employees" as Bogus From Employees
ORDER BY DepartmentID; ---From Employees table

SELECT DepartmentID, ReferenceDescription
FROM ReferenceDescription
UNION Select Null as AllChoice , "All References" as Bogus From ReferenceDescription
ORDER BY DepartmentID; ---from ReferenceDescription table

Now i want to develop query to derive following information:

- All Departments, All Employees and all ReferenceDescription

- Individual departments, All Employees in that department and All ReferenceDescriptions in that Department

- Individual departments, Individual Employees in that department and Individual ReferenceDescriptions in that Department

Please help me building the queiry

Thank you
 
1. What is the point of adding the bogus records to each query?
2. I don't understand what you are trying to do. Are you intending to join the three tables? That won't produce a valid result set. Employees and references have a relationship with departments but have no relationship with each other. If you use them in the same query, you will end up with a Cartesian product which isn't at all what you are looking for.
 

Users who are viewing this thread

Back
Top Bottom