Query Criteria, Part 1: Be specific!

Маңызды :  This article is machine translated, see the disclaimer. Please find the English version of this article here for your reference.

This is part 1 of a 3-part series about using criteria in queries.

Queries are a fundamental part of developing and using any database. In addition to providing a way to make bulk changes to your data, they are how you ask questions about that data. Query criteria help you make your question more specific – so instead of asking "What are my contacts' birthdays?" you could ask "Whose birthdays are coming up next month?"

Let's look at these questions in Access. The first question is a very simple query of a single table (Contacts). It just asks Access to select the name and date of birth of everyone in the table:

Query design with no criteria

When I run the query, I get the full list:

All records returned in query with no criteria

Very basic stuff. In this particular example, I don't have a huge list to look at, but imagine if I had hundreds of contacts. I probably wouldn't be interested in looking up all their birthdays very often. Now let's see how I could use a criterion to ask the more useful question: whose birthdays are this month?

Here's the query design again, only this time I've added an expression in the Criteria row of the DOB field:

Expression in the Criteria row for DOB field

Now when I run the query, I just see folks whose birthdays are this month:

Query criteria returns employees with birthday in current month

You can read more about how query criteria work and get a comprehensive set of examples in the article Examples of query criteria.

Next up: In part 2 of this 3-part series, learn about using the LIKE operator and wildcard characters as criteria.

Ескерту : Machine Translation Disclaimer: This article has been translated by a computer system without human intervention. Microsoft offers these machine translations to help non-English speaking users enjoy content about Microsoft products, services and technologies. Because the article was machine translated, it may contain errors in vocabulary, syntax or grammar.

Дағдыларды жетілдіру
Оқыту курсымен танысыңыз
Жаңа мүмкіндіктерге бірінші болып қол жеткізу
Office Insider бағдарламасына қосылу

Осы ақпарат пайдалы болды ма?

Пікіріңіз үшін рақмет!

Пікіріңізге рақмет! Сізді Office қолдау көрсету қызметіндегі агенттердің бірімен байланыстырған жөн болуы мүмкін.