SQL SELECT and FROM

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

SQL SELECT and FROM

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which query shows only the name and age columns from the students table?
A FROM students SELECT name, age;
B SELECT name, age FROM students;
2. In SELECT name, age FROM students; what does FROM students do?
A It lists the columns to display
B It names the table the data comes from
3. Which query shows every column for every record in the students table?
A SELECT * FROM students;
B SELECT all FROM students;
4. Which query is written correctly?
A SELECT name FROM students;
B SELECT name students FROM;
5. What does SELECT name, age FROM students; return?
A The name and age of every student record
B Only the first student's name and age

Match the Pairs

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

Left columnRight column
1SELECT name, age FROM students; AThere is no comma between the field names. It should be SELECT name, age FROM students;
2SELECT * FROM students; BShows all columns for every record in the students table
3Get just the title and year fields from a table called movies CShows only the name and age columns for every record in the students table
4A SQL statement should end with a semicolon to mark where it finishes DThe FROM keyword is missing, so SQL doesn't know which table to read. It should be SELECT name, age FROM students;
5SELECT name, age students; ESELECT * FROM teams;
6SELECT name age FROM students; FSELECT title, year FROM movies;

Definitions

SELECT name, age FROM students;

Fill in the Blanks

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

1.
______ name, age FROM students;
2.
SELECT name, age ____ students;
3.
SELECT _ FROM students;
4.
SELECT name, age FROM ________;
5.
SELECT name, ___ FROM students;

Spot the Error

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

Question 1
A SELECT name, age
B FROM students;
C SELECT *
D FORM students;
Question 2
A SELECT name, email
B FROM students
C SELECT *
D FROM teachers;
Question 3
A SELECT name, age
B FROM students;
C SELECT year_level house
D FROM students;
Question 4
A SELECT *
B FROM students:
C SELECT name
D FROM students;
Question 5
A SELECT title, author,
B FROM books;
C SELECT *
D FROM books;

Answer Key

SQL SELECT and FROM
Section A: Quick Questions
Q1
B — SELECT name, age FROM students;
Q2
B — It names the table the data comes from
Q3
A — SELECT * FROM students;
Q4
A — SELECT name FROM students;
Q5
A — The name and age of every student record
Section B: Match the Pairs
Q1
SELECT name, age FROM students; → Shows only the name and age columns for every record in the students table
Q2
SELECT * FROM students; → Shows all columns for every record in the students table
Q3
Get just the title and year fields from a table called movies → SELECT title, year FROM movies;
Q4
A SQL statement should end with a semicolon to mark where it finishes → SELECT * FROM teams;
Q5
SELECT name, age students; → The FROM keyword is missing, so SQL doesn't know which table to read. It should be SELECT name, age FROM students;
Q6
SELECT name age FROM students; → There is no comma between the field names. It should be SELECT name, age FROM students;
Section C: Definitions
Q1
SELECT name, age FROM students; — SELECT lists the fields to show and FROM names the table. This returns the name and age columns for every record in students. SELECT * shows all columns. End with a semicolon.
Section D: Fill in the Blanks
Q1
SELECT name, age FROM students;
Q2
SELECT name, age FROM students;
Q3
SELECT * FROM students;
Q4
SELECT name, age FROM students;
Q5
SELECT name, age FROM students;
Section E: Spot the Error
Q1
D — FROM is spelled wrong. The keyword that names the table is FROM, so the line should be FROM students;
Q2
B — The statement is missing its semicolon. A SELECT statement should end with ; so the line should be FROM students;
Q3
C — Fields in a SELECT list must be separated by a comma. It should be SELECT year_level, house
Q4
B — The statement ends with a colon. SQL statements end with a semicolon, so it should be FROM students;
Q5
A — There is an extra comma after the last field. Commas go between fields only, so it should be SELECT title, author