Results 1 to 4 of 4
  1. #1
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291

    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.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    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)?

  3. #3
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    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.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    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.

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums