Difference between revisions of "Update Queries"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Basic Quiz)
 
(3 intermediate revisions by the same user not shown)
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>
 +
 +
{the employee 'Cat Woman' has now moved to a new address ("10 Panther Street").
 +
 +
Which of the following will successfully update the 'Address':
 +
 +
 +
|type="()"}
 +
- Update Employees Set 'Address' = '1 Panther Street'
 +
||Incorrect
 +
+ Update Employees Set 'Address' = '1 Panther Street' Where 'First Name' = 'Cat' And 'Last Name' = 'Woman'
 +
||Correct
 +
- Update Employees Set 'Address' = '1 Panther Street' Where 'Last Name' = 'Woman'
 +
||Incorrect
 +
- Update Employees Set 'Address' = '1 Panther Street' Where 'Name' = 'Cat Woman'
 +
||Incorrect
 +
 +
{the employee 'Tweety Bird' has corrected their address which should be "10 Fowl Avenue" and the city should be 'CanaryVille'.
 +
 +
Which of the following will successfully update the 'Address':
 +
 +
 +
|type="()"}
 +
- Update Employees Set 'Address' = '10 Fowl Avenue' And 'City' = 'CanaryVille' Where 'First Name' = 'Tweety' And 'Last Name' = 'Bird'
 +
||Incorrect
 +
- Update Employees Set 'Address' = '10 Fowl Avenue' And 'City' = 'CanaryVille'
 +
||Incorrect
 +
- Update Employees Set 'Address' = '10 Fowl Avenue', 'City' = 'CanaryVille'
 +
||Incorrect
 +
+ Update Employees Set 'Address' = '10 Fowl Avenue', 'City' = 'CanaryVille' Where 'First Name' = 'Tweety' And 'Last Name' = 'Bird'
 +
||Correct
 +
 +
</quiz>

Latest revision as of 10:30, 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:

Capture.png

1. the employee 'Cat Woman' has now moved to a new address ("10 Panther Street").

Which of the following will successfully update the 'Address':

Update Employees Set 'Address' = '1 Panther Street'
Incorrect
Update Employees Set 'Address' = '1 Panther Street' Where 'First Name' = 'Cat' And 'Last Name' = 'Woman'
Correct
Update Employees Set 'Address' = '1 Panther Street' Where 'Last Name' = 'Woman'
Incorrect
Update Employees Set 'Address' = '1 Panther Street' Where 'Name' = 'Cat Woman'
Incorrect

2. the employee 'Tweety Bird' has corrected their address which should be "10 Fowl Avenue" and the city should be 'CanaryVille'.

Which of the following will successfully update the 'Address':

Update Employees Set 'Address' = '10 Fowl Avenue' And 'City' = 'CanaryVille' Where 'First Name' = 'Tweety' And 'Last Name' = 'Bird'
Incorrect
Update Employees Set 'Address' = '10 Fowl Avenue' And 'City' = 'CanaryVille'
Incorrect
Update Employees Set 'Address' = '10 Fowl Avenue', 'City' = 'CanaryVille'
Incorrect
Update Employees Set 'Address' = '10 Fowl Avenue', 'City' = 'CanaryVille' Where 'First Name' = 'Tweety' And 'Last Name' = 'Bird'
Correct

Your score is 0 / 0