Difference between revisions of "Update Queries"
Line 9: | Line 9: | ||
| UPDATE table SET column1=value1, column2=value2; || Changes column1 to value1, and column2 to value2. | | UPDATE table SET column1=value1, column2=value2; || Changes column1 to value1, and column2 to value2. | ||
|} | |} | ||
+ | |||
+ | ===Basic Quiz=== | ||
+ | All these questions will use this table called Employees: | ||
+ | |||
+ | [[File:Capture.png]] | ||
+ | <quiz display=simple> | ||
+ | |||
+ | {which of the following Insert the following record: | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | | Joe || Bloggs || 1 Some Street || Sheffield || 35 | ||
+ | |} | ||
+ | |||
+ | |type="()"} | ||
+ | + Insert Into Employees ('First Name', 'Last Name', 'Address', 'City', 'Age') Values ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35) | ||
+ | ||Correct | ||
+ | - Insert Into Employees ('First Name', 'Last Name', 'Address', 'City', 'Age') Data ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35) | ||
+ | ||Incorrect | ||
+ | - Insert Into Employees ('First Name', 'Last Name', 'Address', 'Age', 'City') Data ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35) | ||
+ | ||Incorrect | ||
+ | - Insert Into Employees ('First Name', 'Last Name', 'Address', 'Age', 'City') Values ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35) | ||
+ | ||Incorrect | ||
+ | |||
+ | {which of the following statements will Insert the following record: | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | | Fred || Danson || 12 East Road || Leeds || 60 | ||
+ | |} | ||
+ | |||
+ | 1) Insert Into Employees ('First Name', 'Last Name', 'Address', 'City', 'Age') Values ('Fred', 'Danson', '12 East Road', 'Leeds', 60) | ||
+ | |||
+ | 2) Insert Into Employees Values ('Fred', 'Danson', '12 East Road', 'Leeds', 60) | ||
+ | |||
+ | 3) Insert Into Employees Values ('Fred', 'Danson', '12 East Road', 60, 'Leeds') | ||
+ | |||
+ | |||
+ | |type="()"} | ||
+ | - 1 & 2 & 3 | ||
+ | ||Incorrect | ||
+ | + 1 & 2 | ||
+ | ||Correct | ||
+ | - 1 Only | ||
+ | ||Incorrect | ||
+ | - 2 Only | ||
+ | ||Incorrect | ||
+ | |||
+ | </quiz> |
Revision as of 10:18, 28 September 2020
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 column1 values, on every row, to value1 (regardless of their current value). |
UPDATE table SET column1=value1, column2=value2; | Changes column1 to value1, and column2 to value2. |
Basic Quiz
All these questions will use this table called Employees: