Difference between revisions of "Update Queries"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
Line 1: Line 1:
 +
For updating values already entered into a database. Can edit multiple rows at once.  Not using the WHERE clause will cause every entry to be edited.
 +
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
| "UPDATE table SET column1=value1 WHERE column2=value2;" || Example
+
| "UPDATE table SET column1=value1 WHERE column2=value2;" || Changes values in column1 to value1, where column2 equals value2
 
|-
 
|-
| "UPDATE table SET column1=value1;" || Example
+
| "UPDATE table SET column1=value1;" || Sets all values in the table, in column1, to value1 (regardless of their current value).
 
|-
 
|-
| "UPDATE table SET column1=value1, column2=value2;" || Example
+
| "UPDATE table SET column1=value1, column2=value2;" || Changes column1 to value1 and column2 to value2.
 
|}
 
|}
For updating values already entered into a database. Can edit multiple rows at once.  Not using the WHERE clause will cause every entry to be edited.
 
 
 
Editing 'table'
 
: --- Changes values in column1 to value1, where column2 equals value2.
 
:                      --- Sets all values in the table, in column1, to value1 (regardless of their current value).
 
:      --- Changes column1 to value1 and column2 to value2.
 

Revision as of 14:49, 21 December 2016

For updating values already entered into a database. Can edit multiple rows at once. Not using the WHERE clause will cause every entry to be edited.

"UPDATE table SET column1=value1 WHERE column2=value2;" Changes values in column1 to value1, where column2 equals value2
"UPDATE table SET column1=value1;" Sets all values in the table, in column1, to value1 (regardless of their current value).
"UPDATE table SET column1=value1, column2=value2;" Changes column1 to value1 and column2 to value2.