Database Reference
In-Depth Information
Try It: Updating a Row
To change a row's value, open a New Query window in SQL Server Management Studio Express. Enter
the following query, and click Execute:
update MySqlTable
set Name = 'Pearly'
where Id = 3
How It Works
The ID is the SQL-generated unique identifier for rows of the MySqlTable table, so you can use it to
locate the one row we want to update. Running the query should produce a Messages pane reporting “(1
row(s) affected).” Now if you execute the Select * from MySqlTable statement, you will see the modified
records, as shown in Figure 4-5.
Figure 4-5. SELECT statement showing modified row after the UPDATE statement
When you update more than one column, you still use the SET keyword only once, and you separate
the column names and their respective values that you want to set with a comma. For example, the
following statement would change both the name and the Social Security number of a person we have
added to the table:
 
Search WWH ::




Custom Search