For example if you have a table with 1000 entries and you wanted to filter out the results based on a certain criteria, you would use the WHERE clause in your SQL query.
Imagine that you have a table with 1000 entries of people's first names and details about those persons. What if you wanted to view only those records in this table, for people that have the first name of Jack (multiple people have the first name of Jack)? You would use a WHERE clause to specify this filter.
If you remember from the previous readings where I showed how to use the basic SELECT statement on our table called "People", the query to display all the data in the table is typically queried as:
SELECT * FROM People;
But since we want to see only people that have a first name of "Jack", the query would require the filter I mentioned above, called a WHERE clause and it would be written like this:
SELECT * FROM People WHERE FirstName = 'Jack';
This query will give us the name and details of all the people that have a first name of Jack. Literally translated to English, the above SQL statement that demonstrates the WHERE clause would be interpreted like this: "Select all data from the table called People where the field FirstName is equal to 'Jack'". Remember that our People table has a field called FirstName. This is the simplest form of the WHERE clause.
Here we are checking the first name of the people in the database table and seeing if any of them are equal to "Jack", and if they are, only then display the results. This will filter out the people that are not named Jack which is a result that you're looking for.
Another example would be to do the check on the age of the people in the database table. Of the 1000 entries we have in our table, we want to see only result for people that are older than 50 years. The query would then be this:
SELECT * FROM People WHERE Age > 50
Remember in our People table there is a field called Age. This will give us the people and their details only if their age is greater than 50, we will have filtered out people whose age is 50 or less and this is the result that we are looking for.
As you can see, the only difference between this SQL SELECT statement and the ones in the previous reading where I show the most basic SQL SELECT statement is the addition of the WHERE at the end. After the WHERE, is an expression. In our examples, this expression was "FirstName = 'Jack'" and in the second query, "Age > 50". Only rows where this expression is true will get shown from the SELECT statement. That is all there is to writing the basic WHERE clause in your Microsoft Access SQL statements.
Published by Kantus
I love writing short stories and humor articles, but tend to stick with topics that are discoverable by search engines and capable of spreading virally. View profile
- Microsoft Access Tutorial - 4 Steps to Creating a DatabaseA step by step guide to creating your first Microsoft Access database.
- Microsoft Access Tutorial - 5 Steps to Creating a Database TableA Step-by-Step guide to creating your first Microsoft Access database table.
- Microsoft Access - 4 Steps to Adding Data to a Database TableStep by Step guide to adding actual data into a Microsoft Access database table.
- Microsoft Access Tutorial: How to Query an Access TableThis tutorial shows you how to make one of the simplest queries against a table.
Microsoft Access Tutorial: Executing a SELECT StatementA brief overview of how to use simple SELECT statements with an Access database table.
- How to Rid Your Computer of Microsoft Products: Get a Mac
- How to Import Microsoft Excel Data Into Microsoft Access
- Working with Access VBA
- How to Create a Database Using Microsoft Access
- Easy SQL Queries Are in Reach
- Display Table Information by SQL
- Creating a Table in SQL




