How to use SQL Update statement

Web developer uses SQL Update statement to selects all the records that match a specified search expression and then to modify them all according to an update expression. At its simplest, the Update statement has the following format:

UPDATE [table] SET [update_expression] WHERE [search_condition]

Typically, the Update statement to is used to modify a single record. The following example adjusts the phone column in a single vendor record. It uses the unique vendor ID to find the correct row.

UPDATE Vendors SET phone=’888 111-3333′ WHERE ven_id=’678-55-1123′

As with a Select statement, Web developer can use an Update statement with several criteria:

UPDATE Clients SET cli_lname=’Smith’, cli_fname=’Peter’
WHERE cli_lname=’Bush’ AND cli_fname=’John’

Web developer can even use the Update statement to update an entire range of matching records. The following example decreases the price of every book in the Titles table that was published in 2001 by half a dollar:

UPDATE Titles SET price=price-0.5
WHERE pubdate >= ‘2001/01/01’ AND pubdate < ‘2001/01/01’