【译文】查询限制结果记录集(二)
时 间:2014-03-10 09:15:01
作 者:周芳 ID:24526 城市:上海
摘 要:查询限制结果记录集
正 文:
来自:微软 翻译:周芳
【译文】查询限制结果记录集(二)
通常情况下,你不会想从表中检索出所有记录。你只想要得到这些记录中基于一些符合条件标准的一个子集。由此可以限定一个Select语句,这时您必须使用Where子句,这将允许您指定出哪些是你想检索的记录。
VBA
Select *
FROM tblInvoices
Where CustomerID = 1
要明白CustomerID = 1的Where子句的一部分。 Where子句可以包含>40这样的表达式,并且可与and或or 这些逻辑运算符结合。使用多个表达式可以让您进一步过滤记录的结果集。
VBA
Select *
FROM tblInvoices
Where CustomerID = 1 AND InvoiceDate > #01/01/98#
请注意日期字符串需要加上数字符号(#)。如果您使用的是普通的字符串表达式,你必须在该字符串附上单引号('),例如:
VBA
Select *
FROM tblCustomers
Where [Last Name] = 'White'
如果你不知道整个字符串值,您可以使用 Like 通配符。
Select *
FROM tblCustomers
Where [Last Name] LIKE 'W*'
【原文】Restricting the Result Set
More often than not, you will not want to retrieve all records from a table. You will want only a subset of those records based on some qualifying criteria. To qualify a Select statement, you must use a Where clause, which will allow you to specify exactly which records you want to retrieve.
VBA
Select *
FROM tblInvoices
Where CustomerID = 1
Be aware of the CustomerID = 1 portion of the Where clause. A Where clause can contain up to 40 such expressions, and they can be joined with the And or or logical operators. Using more than one expression allows you to further filter out records in the result set.
VBA
Select *
FROM tblInvoices
Where CustomerID = 1 AND InvoiceDate > #01/01/98#
Be aware that the date string is enclosed in number signs (#). If you are using a regular string in an expression, you must enclose the string in single quotation marks ('). For example.
VBA
Select *
FROM tblCustomers
Where [Last Name] = 'White'
If you do not know the whole string value, you can use wildcard characters with the Like operator.
Select *
FROM tblCustomers
Where [Last Name] LIKE 'W*'
Access软件网官方交流QQ群 (群号:483923997) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- Access两种方式实现即时更...(03.01)
- Access隐藏与显示lacc...(01.12)
- 【Access高效办公】将每个...(12.23)
- Access21点游戏源代码(12.13)
- 【Access窗体导出Exce...(11.15)
- 【Access开发】Acces...(11.14)
- 通过Access宏录入数据到选...(11.10)
- 用DLOOKUP函数将需求表中...(10.31)
- Access日期区间段查询数据...(10.25)
学习心得
最新文章
- Access快速开发平台--在WI...(03.08)
- 使用SQL语句删除xscj表中学号...(03.08)
- Access快速开发平台进销存教程...(03.07)
- Access快速开发平台--frm...(03.06)
- 【Access删除查询】删除数字最...(03.06)
- Access快速开发平台进销存教程...(03.05)
- Access快速开发平台进销存教程...(03.04)
- Access快速开发平台--IsL...(03.02)
- Access两种方式实现即时更新月...(03.01)
- Access开发的资金管理系统;基...(02.29)