WHERE Clause Examples

SQL statement

Description

 

SELECT [Last Name], [First Name]
FROM Employees
WHERE [Last Name] = 'King';

Selects the Last Name and First Name fields of each record in which the last name is King.

SELECT [Last Name], [First Name]
FROM Employees
WHERE [Last Name] Like 'S*';

Selects the Last Name and First Name fields for employees whose last names begin with the letter S.

SELECT [Last Name], Salary
FROM Employees
WHERE Salary Between 20000 And 30000;

Selects employees whose salaries are between $20,000 and $30,000, inclusive.

SELECT [Last Name], Salary
FROM Employees
WHERE [Last Name] Between 'Lon'
And 'Tol';

Selects employees whose last names fall in alphabetical order between Lon and Tol, inclusive.  It doesn't retrieve Tolstoy because Tolstoy follows Tol and therefore is outside the specified range.

SELECT [Order ID], [Order Date]
FROM Orders
WHERE [Order Date] Between #1-1-94# And  #6-30-94#;

Selects orders placed during the first half of 1994.

SELECT [Last Name], [First Name], City
FROM Employees
WHERE City In ('Interlaken', 'New York', 'Frankfurt');

Selects employees who live in Interlaken, New York, or Frankfurt.

SELECT Title, [Year Published], Author
FROM Titles, Authors
WHERE Titles.AU_ID = Authors.AU_ID
AND Title LIKE 'A%'

Selects title, year, and author for all titles that start with the letter "A"