Difference between revisions of "Insert Queries"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Changes keyword ambiguity)
Line 16: Line 16:
 
  (value1, value2, value3);
 
  (value1, value2, value3);
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
===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 || Example || 35
 +
|}
 +
?
 +
|type="()"}
 +
+ Select 'First Name', 'Last Name' from Employees
 +
||Correct
 +
- Select * from Employees
 +
||Incorrect
 +
- Select All from Employees
 +
||Incorrect
 +
- Select 'First Name' from Employees
 +
||Incorrect
 +
 +
{which of the following Select queries will select the 'First Name' and 'Last Name' of every employee with the 'Last Name' of 'woman'?
 +
|type="()"}
 +
- Select 'First Name', 'Last Name' from Employees where Employee 'Last Name' = 'woman'
 +
||Incorrect
 +
+ Select 'First Name', 'Last Name' from Employees where 'Last Name' = 'woman'
 +
||Correct
 +
- Select * from Employees where 'Last Name' = 'woman'
 +
||Incorrect
 +
- Select * from Employees where Employee 'Last Name' = 'woman'
 +
||Incorrect
 +
 +
{which of the following Select queries will select the 'First Name' and 'Last Name' of every employee over the age of 50?
 +
|type="()"}
 +
- Select 'First Name', 'Last Name' from Employees where Employee 'Age' < 50
 +
||Incorrect
 +
- Select 'First Name', 'Last Name' from Employees where 'Age' < 50
 +
||Incorrect
 +
- Select 'First Name', 'Last Name' from Employees where Employee 'Age' > 50
 +
||Incorrect
 +
+ Select 'First Name', 'Last Name' from Employees where 'Age' > 50
 +
||Correct
 +
 +
{which of the following Select queries will select the 'First Name' and 'Last Name' of every employee over the age of 50 but under the age of 75?
 +
|type="()"}
 +
- Select 'First Name', 'Last Name' from Employees where Employee 'Age' < 50 And 'Age' > 75
 +
||Incorrect
 +
- Select 'First Name', 'Last Name' from Employees where 'Age' < 50 And < 75
 +
||Incorrect
 +
- Select 'First Name', 'Last Name' from Employees where 'Age' > 50 And <75
 +
||Incorrect
 +
+ Select 'First Name', 'Last Name' from Employees where 'Age' > 50 And Age <75
 +
||Correct
 +
 +
{which of the following Select queries will select the 'First Name' and 'Last Name' of every record in alphabetical order by 'Last Name'?
 +
|type="()"}
 +
+ Select 'First Name', 'Last Name' from Employees Order By 'Last Name'
 +
||Correct
 +
- Select 'First Name', 'Last Name' from Employees Order By 'Last Name' Desc
 +
||Incorrect
 +
- Select 'First Name', 'Last Name' from Employees OrderBy 'Last Name'
 +
||Incorrect
 +
- Select 'First Name', 'Last Name' from Employees OrderBy 'Last Name' Desc
 +
||Incorrect
 +
</quiz>

Revision as of 10:02, 28 September 2020

INSERT adds rows to an existing table, there can be different syntax depending on specific version of SQL etc. For exam questions use one of the methods below. Also remember the values inserted should match the data types of the table fields.

Best Method

 INSERT INTO table_name
 (field1, field2, field3)
 VALUES
 (value1, value2, value3);

Alternative Method

 INSERT INTO table_name
 VALUES
 (value1, value2, value3);

Basic Quiz

All these questions will use this table called Employees:

Capture.png

1. which of the following Insert the following record:

Joe Bloggs 1 Some Street Example 35

?

Select 'First Name', 'Last Name' from Employees
Correct
Select * from Employees
Incorrect
Select All from Employees
Incorrect
Select 'First Name' from Employees
Incorrect

2. which of the following Select queries will select the 'First Name' and 'Last Name' of every employee with the 'Last Name' of 'woman'?

Select 'First Name', 'Last Name' from Employees where Employee 'Last Name' = 'woman'
Incorrect
Select 'First Name', 'Last Name' from Employees where 'Last Name' = 'woman'
Correct
Select * from Employees where 'Last Name' = 'woman'
Incorrect
Select * from Employees where Employee 'Last Name' = 'woman'
Incorrect

3. which of the following Select queries will select the 'First Name' and 'Last Name' of every employee over the age of 50?

Select 'First Name', 'Last Name' from Employees where Employee 'Age' < 50
Incorrect
Select 'First Name', 'Last Name' from Employees where 'Age' < 50
Incorrect
Select 'First Name', 'Last Name' from Employees where Employee 'Age' > 50
Incorrect
Select 'First Name', 'Last Name' from Employees where 'Age' > 50
Correct

4. which of the following Select queries will select the 'First Name' and 'Last Name' of every employee over the age of 50 but under the age of 75?

Select 'First Name', 'Last Name' from Employees where Employee 'Age' < 50 And 'Age' > 75
Incorrect
Select 'First Name', 'Last Name' from Employees where 'Age' < 50 And < 75
Incorrect
Select 'First Name', 'Last Name' from Employees where 'Age' > 50 And <75
Incorrect
Select 'First Name', 'Last Name' from Employees where 'Age' > 50 And Age <75
Correct

5. which of the following Select queries will select the 'First Name' and 'Last Name' of every record in alphabetical order by 'Last Name'?

Select 'First Name', 'Last Name' from Employees Order By 'Last Name'
Correct
Select 'First Name', 'Last Name' from Employees Order By 'Last Name' Desc
Incorrect
Select 'First Name', 'Last Name' from Employees OrderBy 'Last Name'
Incorrect
Select 'First Name', 'Last Name' from Employees OrderBy 'Last Name' Desc
Incorrect

Your score is 0 / 0