Computer Science Grade 7 20 min

Basic Queries

Basic Queries

Tutorial Preview

1

Introduction & Learning Objectives

Learning Objectives Define the terms database, table, and query. Identify the purpose of the SELECT, FROM, and WHERE clauses in a basic query. Write a simple query to retrieve all data from a single table using the '*' wildcard. Write a query to retrieve specific, named columns from a table. Write a query that filters data using a WHERE clause with a single condition. Use comparison operators like '=', '>', and '<' to filter numerical data. How does your favorite music app instantly find a song out of millions? How does a game save your character's level and items? 🎮 They use special questions called queries! In this lesson, you'll become a data detective! You will learn how to ask questions to a database using a spec...
2

Key Concepts & Vocabulary

TermDefinitionExample DatabaseAn organized collection of information, like a giant digital filing cabinet for storing data.A school's database might have information about students, teachers, classes, and grades. TableA set of data arranged in columns and rows within a database. Each table stores information about one specific type of thing.A 'Students' table would have columns for StudentID, FirstName, and Grade. ColumnA vertical category of data in a table that contains a specific type of information for every row.In a 'Students' table, 'FirstName' would be a column. RowA single, horizontal record of data in a table. It represents one complete item.A single row in the 'Students' table might be: 101, 'Ada', 'Lovelace', 7. Q...
3

Core Syntax & Patterns

Select All Pattern SELECT * FROM TableName; Use this to get ALL columns and ALL rows from a table. The asterisk (*) is a wildcard that means 'all columns'. Select Specific Columns Pattern SELECT ColumnName1, ColumnName2 FROM TableName; Use this to get only the specific columns you list from a table. This is useful when you don't need to see every piece of information. Filtering Pattern SELECT ColumnName(s) FROM TableName WHERE Condition; Use this to get only the rows that match a specific condition. The WHERE clause acts like a filter, similar to an 'if' statement in programming.

4 more steps in this tutorial

Sign up free to access the complete tutorial with worked examples and practice.

Sign Up Free to Continue

Sample Practice Questions

Challenging
Student A runs `SELECT CharacterName FROM GameCharacters WHERE Level > 5;`. Student B runs `SELECT * FROM GameCharacters WHERE Level > 5;`. Both queries filter for the same characters. What is the key difference in the output they will see?
A.Student A will see more rows than Student B.
B.Student B will see more rows than Student A.
C.Student A will only see the names of the characters, while Student B will see all information about them.
D.There is no difference in the output.
Challenging
You run the query `SELECT CustomerName FROM Orders WHERE OrderTotal > 100;` to find big spenders. The result is empty, but you are certain there are orders over $100. Based on the common pitfalls, what is the MOST likely error?
A.The table name `Orders` or column name `OrderTotal` is misspelled.
B.You cannot use `>` with numbers over 100.
C.The semicolon at the end is missing.
D.You should have used `SELECT *` instead.
Challenging
A game designer wants to find the name and type of all characters who are exactly level 20. The table is `GameCharacters` and the columns are `CharacterName`, `Level`, and `CharacterType`. Construct the complete and correct query.
A.SELECT * FROM GameCharacters WHERE Level = 20;
B.SELECT CharacterName, CharacterType FROM GameCharacters WHERE Level > 20;
C.SELECT CharacterName, CharacterType FROM GameCharacters WHERE Level = 20;
D.SELECT CharacterName, Level FROM GameCharacters WHERE CharacterType = 20;

Want to practice and check your answers?

Sign up to access all questions with instant feedback, explanations, and progress tracking.

Start Practicing Free

More from Database Concepts

Ready to find your learning gaps?

Take a free diagnostic test and get a personalized learning plan in minutes.