D
Don
Thanks to some help from Bob Barrows, I got the following query working in
Access 2003:
SELECT A.Building, A.AptNum, R.Name, R.AptNum, R.Status, P.Number,
P.Type
FROM tblApartments AS A
INNER JOIN (tblPhones AS P
INNER JOIN tblResidents AS R
ON P.ResID = R.ResID)
ON R.AptNum = A.AptNum
WHERE A.Building = 3
AND R.Status = 'Moved'
AND P.Type = 'Work';
One difficulty I ran into was that people without a work number were not
being listed. Figured "no problem" just use a LEFT JOIN and away I go.
However using 'LEFT' or 'LEFT OUTER' does not work.
SELECT A.Building, A.AptNum, R.Name, R.AptNum, R.Status, P.Number,
P.Type
FROM tblApartments AS A
INNER JOIN (tblPhones AS P
LEFT OUTER JOIN tblResidents AS R
ON P.ResID = R.ResID)
ON R.AptNum = A.AptNum
WHERE A.Building = 3
AND R.Status = 'Moved'
AND P.Type = 'Work';
results in an "Join expression not Supported." error. But if I understand
the following from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acintsql.asp
"OUTER JOINs can be nested inside INNER JOINs in a multi-table join, but
INNER JOINs cannot be nested inside OUTER JOINs."
I would assume the JOIN between Residents and PhoneNumbers is the inside of
the nesting. For a quick test I made the first INNER JOIN a LEFT OUTER JOIN
and got a syntax error. So it sort of supports my assumption.
On a related topic, is the Access SQL syntax (specifically the nesting of
joins) compatible with SQL Server syntax?
Any help will be greatly appreciated!!
Thanks!
Don
Access 2003:
SELECT A.Building, A.AptNum, R.Name, R.AptNum, R.Status, P.Number,
P.Type
FROM tblApartments AS A
INNER JOIN (tblPhones AS P
INNER JOIN tblResidents AS R
ON P.ResID = R.ResID)
ON R.AptNum = A.AptNum
WHERE A.Building = 3
AND R.Status = 'Moved'
AND P.Type = 'Work';
One difficulty I ran into was that people without a work number were not
being listed. Figured "no problem" just use a LEFT JOIN and away I go.
However using 'LEFT' or 'LEFT OUTER' does not work.
SELECT A.Building, A.AptNum, R.Name, R.AptNum, R.Status, P.Number,
P.Type
FROM tblApartments AS A
INNER JOIN (tblPhones AS P
LEFT OUTER JOIN tblResidents AS R
ON P.ResID = R.ResID)
ON R.AptNum = A.AptNum
WHERE A.Building = 3
AND R.Status = 'Moved'
AND P.Type = 'Work';
results in an "Join expression not Supported." error. But if I understand
the following from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acintsql.asp
"OUTER JOINs can be nested inside INNER JOINs in a multi-table join, but
INNER JOINs cannot be nested inside OUTER JOINs."
I would assume the JOIN between Residents and PhoneNumbers is the inside of
the nesting. For a quick test I made the first INNER JOIN a LEFT OUTER JOIN
and got a syntax error. So it sort of supports my assumption.
On a related topic, is the Access SQL syntax (specifically the nesting of
joins) compatible with SQL Server syntax?
Any help will be greatly appreciated!!
Thanks!
Don