Update queries using more than one table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sn0wman
    New Member
    • Aug 2014
    • 2

    #1

    Update queries using more than one table

    I am an Access 2010 novice who is trying to update one table with information from another i.e. when table 1 col 1 = table 2 col 1, update table 1 col 2 with table 2 col 2, but keep getting syntax errors when using the following code. Can anyone help point out where I am going wrong.

    Code:
    UPDATE TrafficApr11toDate 
    SET [Originating Country] = (SELECT OriginatingCountry.[Mapped Originating Country],
    FROM OriginatingCountry
    WHERE OriginatingCountry.[Intermediate Originating Country] = TrafficApr11toDate.[Originating Country (Original)]);
    Last edited by Rabbit; Aug 21 '14, 04:04 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • jforbes
    Recognized Expert Top Contributor
    • Aug 2014
    • 1107

    #2
    I think this is what you are attempting to do

    Code:
    UPDATE TrafficApri11toDate 
    LEFT JOIN OriginatingCountry 
    ON TrafficApri11toDate.[Originating Country (Original)] = OriginatingCountry.[Intermediate Originating Country] 
    SET TrafficApri11toDate.[Originating Country] = [OriginatingCountry].[Mapped Originating Country];
    Access does things a little strange sometimes when using the Query Editor. It always makes me uncomfortable when there is no FROM statement.

    Comment

    • Sn0wman
      New Member
      • Aug 2014
      • 2

      #3
      Thanks very much .....that's sorted it out although you did throw me for 10mins as one of the tables got renamed in your reply ;-).

      Comment

      Working...