Adding a WHERE clause to a SELECT statement retrieves only those records that meet a specific condition. .
SELECT * FROM Employees WHERE GivenName = 'John'
EmployeeID |
ManagerID |
Surname |
GivenName |
DepartmentID |
... |
---|---|---|---|---|---|
318 |
1,576 |
Crow |
John |
400 |
... |
862 |
501 |
Sheffield |
John |
100 |
... |
1,483 |
1,293 |
Letiecq |
John |
300 |
... |
The apostrophes (single quotes) around the name 'John' are required. They indicate that John is a character string. Quotation marks (double quotes) have a different meaning. Quotation marks can be used to make otherwise invalid strings valid for column names and other identifiers.
The sample database is not case sensitive, so you would get the same results whether you searched for ' 'JOHN', 'john', or 'John'.
Again, you can combine what you have learned:
SELECT GivenName, Surname, BirthDateFROM Employees WHERE GivenName = 'John' ORDER BY BirthDate