After SELECTing some data, you can filter it using
WHERE.
Example 1 shows the SQL statement to SELECT all fields from Students WHERE the first name is "William".
Example 1
SELECT *
FROM Students
WHERE FirstName
= "William"
Table 1 shows the output of Example 1.
Table 1
| StudentID | FirstName | LastName | DateOfBirth |
|---|---|---|---|
| 1225 | William | Smith | 15/04/2009 |
| 1228 | William | Jones | 13/09/2008 |
The boolean operators AND and OR can also be used
in WHERE clauses.
Write a SQL statement to
SELECT the first and last names of all students called William, OR whose ID is equal to 1227.
Tap/click to reveal
SELECT FirstName, LastName
FROM Students
WHERE FirstName
= "William" OR
StudentID = 1227