Examples of Query Criteria

Criteria are intended for a conclusion in query only to that information which is necessary for the user (not all field content). The most often criteria applied in Access are numerical and text. Let's consider their formation:

Text criteria - the most widespread type of conditions. Several various ways of input are allowed:

· "Ivanov"

· ="Ivanov"

· = Ivanov

· Ivanov

Each of these ways will result in the same result - only those records in which respective field data matter "Ivanov" will be removed.

Besides, in text conditions the Like operator and a symbol " * " is widely applied (any quantity of any symbols). The Like operator serves for formation of a subset of text values. For example:

like I* - all text values beginning on the letter "I" will be displayed.

like [A-L]* - the values beginning with A on L inclusive are displayed.

 

In text criteria it is also possible to use the operator OR, for example "Ivanov" or "Petrov"

Numerical criteria - One of the most widespread types of criteria also. In numerical criteria comparison signs are applied: >, <, >=, <=, =, <>. Besides, the operator between is applied that allows to specify an interval of values, for example of between 1 and 100 is applied - will display values from 1 to 100. One can use logical operator or.

Use of logical operations "And" and "OR"

The " And " operator is used when accomplishment of several conditions for different fields at the same time is necessary. For this purpose in the line " Criteria " the necessary condition registers under each of that field for which they shall be executed. For example, let in the table Worker it is necessary to choose assemblers, with payment at least 70000. Let's enter in line " Criteria " under the field Profession - the line " Assembler ", and under the field Salary - a line >=70000. In case of start of a query these criteria will be satisfied.

The operation " OR " is used in cases when data in the field can accept one of several concrete values. The line " or " of the form of query is for this purpose used. Let, for example we need information about electricians, assemblers and carpenters. Then in line " Criteria " under the field " Profession " we will write down " electrician ", below, in the line " or " we will write down " assembler ", is even lower - " carpenter ". Thus, the necessary criteria of selection will be created.

The operations " AND " and " OR " can be combined. For example, considered by us above a condition can be combined in one query as follows:


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: