-
SQL Query help
So the statement last week worked
SELECT Inspections.ID, Inspections.[Manhole Number (12)], Inspections.[Rim to Invert (13)], IIf([Wall Diameter]>[Wall Diameter 2],[Wall Diameter],[Wall Diameter 2]) AS WallDiameter
FROM Inspections;
but now I would like to display the same stuff + another item from a different table that is connected to the original table & record.
I tried
SELECT Inspections.ID, Inspections.[Manhole Number (12)], Inspections.[Rim to Invert (13)], IIf([Wall Diameter]>[Wall Diameter 2],[Wall Diameter],[Wall Diameter 2]) AS WallDiameter, [Inspections Detail].[PACP Defect]
FROM Inspections INNER JOIN [Inspections Detail] ON Inspections.ID = [Inspections Detail].ID;
but it doesnt bring up anything when I open the query. any help on the syntax? Thank you.
-
Are you using the query builder to create the query? Try a LeftJoin and see if you get any records. Are the two ID fields the same type of field (Long Integer perhaps)?
-
Inspections.ID is an AutoNumber and a Long Integer
[Inspections Detail].ID is a Number and a Long Integer
Inspections.ID has a One-to-Many relationship with [Inspections Detail].ID
I tried doing it without the query and with the query and neither one worked but I just put in LEFT instead of INNER and it worked, thank you.
-
INNER *only* shows records where the fields match. LEFT (or OUTER JOIN) shows *all* of the records from one table filling in the field from the other table when they match. The fact that you were not getting any records with the INNER join tells me there were no records where the two ID fields matched.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules