UPDATE Based Off of A Table

  • 1

UPDATE Based Off of A Table

visit : http://www.zonixsoft.com (our official website)

 INSERT offers the ability to insert into a table based upon a SELECT statement with the following syntax:

INSERT INTO [TABLEA] ([FIELDA],[FIELDB],[FIELDC])
        SELECT [FIELDA],[FIELDB],[FIELDC]
FROM [TABLEB]

 

there are time where you may want to do a similar approach with UPDATE.
Here is the syntax to do that very task:

UPDATE [TABLEA]
        SET  [TABLEA].[FIELDA] = [TABLEB].[FIELDA]
               [TABLEA].[FIELDB] = [TABLEB].[FIELDB]
               [TABLEA].[FIELDC] = [TABLEB].[FIELDC]
        FROM [TABLEA]
               JOIN [TABLEB]
        ON [TABLEA].[KEYA] = [TABLEB].[KEYA]

 


Bookmark and Share