Вы находитесь на странице: 1из 5

Examples of query criteria

Criteria for Text, Memo, and Hyperlink fields


If you want to see a demo of criteria that you can use with text fields, see the article
Watch this: Specify criteria for a text field.

To include records
Use this criterion Query result
that...
Exactly match a
value, such as "PGDCA" Returns records where the Course field is set to PGDCA.
PGDCA
Do not match a
Returns records where the Course field is set to a Course
value, such as Not "PGDCA"
other than PGDCA.
PGDCA
Returns records for all Name whose names start with "S",
such as Siba, Sunita and so on.
Begin with the
specified string, such Like S* Note When used in an expression, the asterisk (*)
as S represents any string of characters it is also called a
wildcard character. For a list of such characters, see the
article Access wildcard character reference.
Do not begin with
Returns records for all Names whose names start with a
the specified string, Not Like S*
character other than "S".
such as S
Contain the specified
Like "*R*" Returns records for all names that contain the string "R".
string, such as R
Do not contain the
Returns records for all names that do not contain the
specified string, such Not Like "*R*"
string "R".
as R
End with the
specified string, such Like "*a" Returns records for all Names whose names end in "a".
as "a"
Do not end with the
specified string, such Not Like "*a" Returns records for all names that do not end in "a.
as "a"
Contain null (or
Is Null Returns records where there is no value in the field.
missing) values
Do not contain null
Is Not Null Returns records where the value is not missing in the field.
values
Fall within a specific
Returns records for names whose names start with the
range, such as A Like "[A-D]*"
letters "A" through "D".
through D
To include records
Use this criterion Query result
that...
Match one of two
values, such as CCA "CCA" Or "DCA" Returns records for CCA and DCA.
or DCA
In("Pudamari",
Contain one of the
"Digapahandi",
values in a list of Returns records for all City specified in the list.
"Pattapur",
values
"Dengausta")
Satisfy length Len([CountryRegion]) > Returns records for countries/regions whose name is
requirements 10 more than 10 characters long.
Returns records for countries/regions, such as China and
Match a specific
Like "Chi??" Chile, whose names are five characters long and the first
pattern
three characters are "Chi".

Criteria for Number, Currency, and AutoNumber


fields

To include Use this


Query Result
records that... criterion
Exactly match a
value, such as 100 Returns records where the unit price of the product is $100.
100
Do not match a
value, such as Not 1000 Returns records where the unit price of the product is not $1000.
1000
Contain a value
Returns records where the unit price is less than $100 (<100). The second
smaller than a < 100
expression (<=100) displays records where the unit price is less than or
value, such as <= 100
equal to $100.
100
Contain a value
Returns records where the unit price is greater than $99.99 (>99.99). The
larger than a >99.99
second expression displays records where the unit price is greater than or
value, such as >=99.99
equal to $99.99.
99.99
Contain one of
the two values, 20 or 25 Returns records where the unit price is either $20 or $25.
such as 20 or 25
>49.99 and
Contain a value <99.99
Returns records where the unit price is between (but not including)
that falls with a -or-
$49.99 and $99.99.
range of values Between 50
and 100
To include Use this
Query Result
records that... criterion
Contain a value
that falls outside <50 or >100 Returns records where the unit price is not between $50 and $100.
a range
Contain one of
In(20, 25,
many specific Returns records where the unit price is either $20, $25, or $30.
30)
values
Contain a value
that ends with Returns records where the unit price ends with "4.99", such as $4.99,
Like "*4.99"
the specified $14.99, $24.99, and so on.
digits
Contain null null
(or missing) Is Null Returns records where no value is entered in the UnitPrice field.
values
Contain non-null
Is Not Null Returns records where the value is not missing in the UnitPrice field.
values

Criteria for Date/Time fields


To include records that Use this criterion Query result
Returns records of transactions
that took place on Feb 2, 2006.
Remember to surround date
Exactly match a value,
#2/2/2006# values with the # character so
such as 2/2/2006
that Access can distinguish
between date values and text
strings.
Returns records of transactions
Do not match a value,
Not #2/2/2006# that took place on a day other
such as 2/2/2006
than Feb 2, 2006.
Returns records of transactions
that took place before Feb 2,
2006.
Contain values that fall
before a certain date, < #2/2/2006#
To view transactions that took
such as 2/2/2006
place on or before this date, use
the <= operator instead of the <
operator.
Returns records of transactions
that took place after Feb 2, 2006.
Contain values that fall
after a certain date, such > #2/2/2006# To view transactions that took
as 2/2/2006 place on or after this date, use
the >= operator instead of the >
operator.
To include records that Use this criterion Query result
Returns records where the
transactions took place between
Feb 2, 2006 and Feb 4, 2006.

You can also use the Between


Contain values that fall
>#2/2/2006# and <#2/4/2006# operator to filter for a range of
within a date range
values, including the end points.
For example, Between
#2/2/2006# and #2/4/2006# is
the same as >=#2/2/2006# and
<=#2/4/2006# .
Returns records where the
Contain values that fall
<#2/2/2006# or >#2/4/2006# transactions took place before
outside a range
Feb 2, 2006 or after Feb 4, 2006.
Contain one of two Returns records of transactions
values, such as 2/2/2006 #2/2/2006# or #2/3/2006# that took place on either Feb 2,
or 2/3/2006 2006 or Feb 3, 2006.
Returns records where the
Contain one of many transactions took place on Feb 1,
In (#2/1/2006#, #3/1/2006#, #4/1/2006#)
values 2006, March 1, 2006, or April 1,
2006.
Contain a date that falls
Returns records where the
in a specific month
DatePart("m", [SalesDate]) = 12 transactions took place in
(irrespective of year),
December of any year.
such as December
Returns records of transactions
Contain today's date Date() that took place on the current
day.
Returns records of transactions
that took place the day before
Contain yesterday's date Date()-1 the current day. If today's date is
2/2/2006, you see records for
Feb 1, 2006.
Returns records of transactions
that took place the day after the
Contain tomorrow's
Date() + 1 current day. If today's date is
date
2/2/2006, you see records for
Feb 3, 2006.
Returns records of transactions
that took place during the last 7
Contain a date that fell days. If today's date is 2/2/2006,
Between Date() and Date()-6
during the last 7 days you see records for the period
Jan 24, 2006 through Feb 2,
2006.
Contain a date that Year([SalesDate]) = Year(Now()) And Returns records for the current
To include records that Use this criterion Query result
belongs to the current Month([SalesDate]) = Month(Now()) month. If today's date is
month 2/2/2006, you see records for
Feb 2006.
A month's worth of sales
Contain a date that fell records. If today's date is
Between Date( ) And DateAdd("M", -1, Date(
during the last 30 or 31 2/2/2006, you see records for
))
days the period Jan 2, 2006. to Feb 2,
2006
Returns records for the current
Contain a date that falls year. If today's date is 2/2/2006,
Year([SalesDate]) = Year(Date())
during the current year you see records for the year
2006.
Returns records of transactions
Contain a date that that took place during the
belongs to the previous Year([SalesDate]) = Year(Date()) - 1 previous year. If today's date is
year 2/2/2006, you see records for
the year 2005.
Returns records of transactions
Contain a date that with next year's date. If today's
Year([SalesDate]) = Year(Date()) + 1
belongs to next year date is 2/2/2006, you see
records for the year 2007.
Returns records of transactions
with dates that fall between Jan 1
Contain a date that falls Year([SalesDate]) = Year(Date()) and
of the current year and today. If
between Jan 1 and today Month([SalesDate]) <= Month(Date()) and
today's date is 2/2/2006, you see
(year to date records) Day([SalesDate]) <= Day (Date())
records for the period Jan 1,
2006 to to 2/2/2006.
Contain a date that Returns records of transactions
< Date()
occurred in the past that took place before today.
Contain a date that Returns records of transactions
> Date()
occurrs in the future that will take place after today.
Filter for null (or missing) Returns records where the date
Is Null
values of transaction is missing.
Returns records where the date
Filter for non-null values Is Not Null
of transaction is known.

Criteria for other fields


Yes/No fields In the Criteria row, type Yes to include records where the check box is selected. Type No
to include records where the check box is not selected.

Attachments In the Criteria row, type Is Null to include records that do not contain any attachments.
Type Is Not Null to include records that contain attachments.

Вам также может понравиться