RelationalDBDesign
SiteMap
Business Rules
Cursors Views
Database Creation
SQL Monitoring
Database Web Apps
Data Manipulation
Access Features
Tables Queries
Basic Queries
«Prev
Database Web Applications
Database Concepts
Table Structures
SQL
Data Binding
Basic Queries
SQL Select Statement
SQL Where Clause
Sort Results Orderby
Modify Records Update
SQL Insert Statement
Delete Table Row
SQL Capability Conclusion
Data Access
Binding DataBound DesignTime Controls
Scripting with Recordsets
Defensive Programming Handling Errors
Modifying Data
Updating Database Records
Data Types Databases
Direct Database Access
Using the Update statement in SQL - Server
UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value;
This part of the UPDATE statement specifies the table that will be updated
The SET clause specifies the column names and new data values to store in the column
Change the values in the specified columns in all the rows in the table.
When a customer purchases a book from the VirtualBookShelf.com website, the application should decrease the Qty column by the number purchased.
The SET clause specifies the column name and new value. In this example, 1 is subtracted from the current value of Qty and the result is stored in the Qty column.
Where clause specifies the row. This statement reduces the Qty column by one in each row where the book title is.
This example assumes only one book of the specified title was purchased, so setting the new value with the expression Qty = Qty -1 is appropriate.
Portion of the BookTable before the UPDATE statement is executed.
Here is the BookTable after the UPDATE statement has executed.