Ms Access 简明教程
MS Access - Alternate Criteria
查询有很多优势。您可以保存并多次运行相同的查询,并且很多时候您想要添加备选条件。
Queries come in with many advantages. You can save and run the same query again and again, and a lot of times you want to add alternate criteria.
您可以通过以下两种方式添加备选条件:
You can add alternate criteria in the following two ways −
-
You can use the OR operator to combine two sets of criteria.
-
You can also use the query design grid, but instead of specifying criteria on the same line, you will need to separate it in multiple row.
Example
让我们看一个备选条件的简单示例。打开数据库,然后在“创建”选项卡中选择 Query Design 。
Let us look at a simple example of alternate criteria. Open database and in the Create tab select Query Design.
双击 tblEmployee 然后关闭“显示表”对话框。
Double-click on tblEmployee and close the Show Table dialog box.
双击您希望作为查询结果查看的所有字段。
Double-click on all the field you want to see as query result.
您现在可以看到备用条件在 LastName 字段的不同行中指定。当您运行此查询时,您将看到姓氏为 Pollard 或 Manning 的员工。现在让我们来运行此查询。
You can now see that alternate criterion is specified in different rows of the LastName field. When you run this query, you will see the employees whose last name is either Pollard or Manning. Let us now run this query.
如您所见,由于备用条件,只有两名员工被检索到。
As you can see that only two employees have been retrieved, because of the alternate criteria.
如果您希望在多个字段中添加备用条件,那么您将必须对所有字段使用不同的行。现在,让我们添加另一个备用条件,我们可以在其中检索姓氏为 Pollard 或 Manning 或职称为 Accounting Assistant 的员工的信息。
If you want to add alternate criteria in multiple fields then you will have to use different rows for all the fields. Let us now add another alternate criterion where we can retrieve information for employees whose last name is either Pollard or Manning or the job title is Accounting Assistant.
现在让我们来运行此查询。
Let us now run this query.
您现在将看到以下结果。
You will now see the following result.