SQL Nested Inner Joins? Help!

Status
Not open for further replies.

FormerlyDZone

Ars Praefectus
4,581
Subscriptor
Ok guys I'll admit this is homework but I've spent two days trying to figure out how to do this last query and I'm simply stumped. I'm pretty sure I know, intellectually how to do it but I can't figure out the syntax to save my life.

Is my logic wrong, if so can someone point me in the right direction or help me with the syntax?

Question

Using access

4 tables with the relevant fields listed

software SID, TITLE
config SID,HID
hardware HID,EID
employee EID,FName,LName


I need to prompt the user for a software title (the access sytnax for this is square brackets in the where clause ie WHERE [] _)

look up the corresponding software id (SID) from software then
select the HID of the computers with the software installed (HID) from config then
find the first and last names of the employees with the software installed (Match HID to corresponding EID in hardware then select Fname and Lname from employee EID)

I figure I need something like this but I can't get the syntax
Code:
SELECT FName, LName FROM employee Inner Join (hardware Inner Join (config Inner Join (software
ON software.SID=config.SID) ON config.EID=hardware.EID) ON hardware.EID=employee.EID) WHERE software.title=[Enter Title]


Thanks for any help guys
 

FormerlyDZone

Ars Praefectus
4,581
Subscriptor
Thanks Richard that got me on the right track, from there it was easier to see where the parenthesis needed to go since Access shreds mysql :p

Here's the correct syntax for any search engine goers who find this.


Code:
SELECT FName, LName 
FROM (((tblEmployee AS e 
Inner Join tblHardware AS h 
ON e.EID=h.AssignedTo )
Inner Join tblConfig as c 
ON h.HID=c.HID) 
Inner Join tblSoftware as s 
ON c.SID=s.SID) 
WHERE s.title=[Enter Title];
 
Status
Not open for further replies.