Returning all data from a table
Select some columns
Filtering rows
5. Select only a few rows
Logic
Text patterns
To be or NULL to be
A bit of mathematics
Let's practice

Instruction

Our table is pretty small, so if we wanted to get some information about Volkswagens, we could select all rows and just ignore the extra few that contain other brands. But what if our table consisted of thousands of rows? In that case, we couldn't possibly go through all the results trying to find the rows that we want to look at. Instead, we can filter the results like so:

SELECT
  *
FROM User
WHERE Id = 100;

Look what happened – we've added the WHERE keyword and a condition. The simplest is an equality. In our case, we want to retrieve information about a user with a specific ID (100), so we use an equality (Id = 100).

Exercise

Select all columns for cars produced in 1999. Use the ProductionYear column.

Stuck? Here's a hint!

Type:

SELECT
  *
FROM Car
WHERE ProductionYear = 1999;