Changing Data Using the FROM Clause

Accessing and Changing Relational Data

Accessing and Changing Relational Data

Changing Data Using the FROM Clause

Use the FROM clause to pull data from one or more tables or views into the table you want to update. For example, when author Dirk Stringer gets a contract, a title identification number is assigned to his book, The Psychology of Computer Cooking, in the titles table. Dirk's row in the titleauthor table can be updated by adding a title identification number for this latest book.

This example updates Dirk Stringer's row in the titleauthor table to add a title identification number for his latest book:

UPDATE titleauthor
   SET title_id = titles.title_id
   FROM titles INNER JOIN titleauthor 
      ON titles.title_id = titleauthor.title_id 
      INNER JOIN authors
      ON titleauthor.au_id = authors.au_id
   WHERE titles.title = 'Net Etiquette'
      AND au_lname = 'Locksley'

To update data using UPDATE

Transact-SQL

See Also

FROM

WHERE

UPDATE