Microsoft Access Database Development With VBA

SQL Keywords: WHERE

   

Description

The WHERE keyword is used to specify a criterion or condition, criteria or conditions, that a SQL statement must follow to perform its operation.

The WHERE keyword can be used in a SELECT statement to specify what criterion the statement must follow to select one or more records. The formula to follow is:

SELECT What FROM WhatObject WHERE Expression;

Here is an example where all records are selected from a table but only records where the Gender value is Male would be kept:

SELECT * FROM Students WHERE Gender="Male";

Here is an example where the names of of tables and columns are included in square brackets and the names of columns are qualified with periods:

SELECT [Students].[FirstName], [Students].[LastName]
FROM [Students]
WHERE [Students].[Gender]="Male";

Here is an example that uses the <> operator:

SELECT * FROM Students WHERE Gender <> "Male";

See Also

   
     
 

Home Copyright © 2012-2013 FunctionX, Inc. Home