【译文】查询限制结果记录集(二)
时 间: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群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 用Access连续窗体制作的树...(11.03)
- 【Access高效办公】上一年...(10.30)
- Access制作的RGB转CM...(09.22)
- Access制作的RGB调色板...(09.15)
- Access制作的快速车牌输入...(09.13)
- 【Access高效办公】统计当...(06.30)
- 【Access高效办公】用复选...(06.24)
- 根据变化的日期来自动编号的示例...(06.20)
- 【Access高效办公】按日期...(06.12)
学习心得
最新文章
- Access快速开发平台企业版--...(12.10)
- SqlServer默认当前时间用什...(11.28)
- 【Access日期时间区间段查询示...(11.19)
- Microsoft Access不...(11.07)
- 用Access连续窗体制作的树菜单...(11.03)
- 【Access高效办公】上一年度累...(10.30)
- Access做的一个《中华经典论语...(10.25)
- Access快速开发平台--加载事...(10.20)
- 【Access有效性规则示例】两种...(10.10)
- EXCEL表格扫描枪数据录入智能处...(10.09)


.gif)
