Choosing which fields a query shows

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Choosing which fields a query shows

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. You only want to see each student's Name and Score. Which query does that?
A SELECT Name, Score FROM Students
B SELECT Name Score FROM Students
2. What does SELECT * FROM Students show?
A Every field in the Students table
B Only the first field in the table
3. SELECT Name, Score FROM Students. What happens to the other columns, like Age and Year?
A They are left out of the result
B They are shown at the end of the result
4. Which query shows Score first and then Name?
A SELECT Name, Score FROM Students
B SELECT Score, Name FROM Students
5. You want every column from the Students table without typing each field name. Which is best?
A SELECT All FROM Students
B SELECT * FROM Students

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1SELECT Name, Score FROM Students ASELECT Name FROM Students
2SELECT * FROM Students BSELECT Score, Name FROM Students
3Show only a student's Score and then their Name, in that order CNo fields are listed after SELECT. Add field names, or use * to show all fields.
4Show just one field, Name, so the other columns are hidden DThe field names are missing a comma between them. It should be SELECT Name, Score FROM Students.
5SELECT Name Score FROM Students EShows only the Name and Score columns for every student, and leaves out all other fields
6SELECT FROM Students FShows every field in the Students table

Definitions

SELECT Name, Score FROM Students

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
______ Name, Score FROM Students
2.
SELECT Name, _____ FROM Students
3.
SELECT _ FROM Students
4.
SELECT Name, Score ____ Students
5.
SELECT _____, Name FROM Students

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A SELECT Name Score
B FROM Students
C WHERE Score > 50;
Question 2
A SELECT Name, Score
B FORM Students
C ORDER BY Score DESC;
Question 3
A SELECT Name, Score
B FROM Students
C WHERE Score >= 80
D ORDER BY Marks;
Question 4
A SELECT *
B FROM Students
C WHERE Year == 8;
Question 5
A SELECT Name, Score
B FROM Students
C WHERE Year = 7
D ORDER BY Score DOWN;

Answer Key

Choosing which fields a query shows
Section A: Quick Questions
Q1
A — SELECT Name, Score FROM Students
Q2
A — Every field in the Students table
Q3
A — They are left out of the result
Q4
B — SELECT Score, Name FROM Students
Q5
B — SELECT * FROM Students
Section B: Match the Pairs
Q1
SELECT Name, Score FROM Students → Shows only the Name and Score columns for every student, and leaves out all other fields
Q2
SELECT * FROM Students → Shows every field in the Students table
Q3
Show only a student's Score and then their Name, in that order → SELECT Score, Name FROM Students
Q4
Show just one field, Name, so the other columns are hidden → SELECT Name FROM Students
Q5
SELECT Name Score FROM Students → The field names are missing a comma between them. It should be SELECT Name, Score FROM Students.
Q6
SELECT FROM Students → No fields are listed after SELECT. Add field names, or use * to show all fields.
Section C: Definitions
Q1
SELECT Name, Score FROM Students — A query that lists the fields to show. Only Name and Score appear, in that order, so other columns are left out. SELECT * shows every field.
Section D: Fill in the Blanks
Q1
SELECT Name, Score FROM Students
Q2
SELECT Name, Score FROM Students
Q3
SELECT * FROM Students
Q4
SELECT Name, Score FROM Students
Q5
SELECT Score, Name FROM Students
Section E: Spot the Error
Q1
A — The fields to show must be separated by a comma. It should be SELECT Name, Score.
Q2
B — The keyword is spelled wrong. It should be FROM Students, which names the table the fields come from.
Q3
D — The table has no field called Marks. The field in the SELECT list is Score, so it should be ORDER BY Score.
Q4
C — A query uses a single = to compare values. It should be WHERE Year = 8;. SELECT * shows every field for the matching rows.
Q5
D — To sort from highest to lowest, the keyword is DESC, not DOWN. It should be ORDER BY Score DESC;.