Works: Database Query Examples (76287)



The information in this article applies to:

  • Microsoft Works 2.0
  • Microsoft Works 2.0a
  • Microsoft Works 3.0
  • Microsoft Works 3.0a
  • Microsoft Works 3.0b
  • Microsoft Works 4.5
  • Microsoft Works 4.5a
  • Microsoft Works for Windows 95, version 4.0
  • Microsoft Works for Windows 95, version 4.0 4.0a

This article was previously published under Q76287

SUMMARY

Before you print a report or view a database in Microsoft Works, you can define exactly which records you want to see by using a Query (Works 2.0 and 3.0) or Filter (Works 4.0 for Windows 95). With a Query or Filter, you can ask for specific field definition. In contrast, the Search command will check all fields and records for what you ask.

MORE INFORMATION

With Works for Windows 2.0 and 3.0, you select a specific group of records by typing one or more conditions in query fields. In Works 4.0, you can select Filter conditions in the Easy Filter dialog, or use the Filter using formula option. Each condition defines the text or values you want Works for Windows to look for.

The following is a list of operators, formulas, and the expected results.
 Operator              Formula Used        Finds These Records
 --------              ------------        -------------------

 Equal to (=)          Smith or ="Smith"   Last name is Smith

 Equal to (=)          25 or =25           The number is 25

 Not Equal (<>)        <>"Ca"              Finds all states
                                           excluding Ca

 Begins with ="x*"     ="J*"               Last name begins with "J"

 Greater than          >="J"               Last names beginning with
   or equal to (>=)                        "J" and after "J"
                                           alphabetically

 Greater than                              The date is October 30,
   or equal to (>=)    >='10/30/60'        1960 or later

 Greater than (>)      >25                 Number is greater than 25

 Empty
   Works 2.0:          ==0                 Field is blank
   Works 3.0 and 4.0:  =fieldname=""

 Non Empty
   Works 2.0:          <>==0               Field is nonblank
   Works 3.0 and 4.0:  =fieldname<>""
				
Works for Windows will also work with multiple arguments and functions. The following are examples using OR and AND operators.

  • In Works 2.0, the OR operator is a straight vertical line (|), known as the pipe character, and the AND operator is the ampersand (&).

  • In Works 3.0 and Works 4.0, the OR operator is #OR#, and the AND operator is #AND#.
NOTE: In the examples below, if you are using Works 3.0 or later, substitute #AND# and #OR# for the & and | operators, respectively.
 Operator         Formula Used             Finds These Records
 --------         ------------             -------------------

 Or (|)           =fieldname='1/01/91'|    Date is 1/01/91 or
                  fieldname='8/30/91'      8/30/91

 And (&)          >='1/01/91'&<'8/30/91'   Month is greater than or
                                           equal to 1/01/91 and less
                                           than 8/30/9

 Between (>x&<x)  >25&<75                  Greater than 25 and less
                                           than 75

 Month function   =month(fieldname)=10|    Month is equal to the 10th
                   month(fieldname)=12     month or the 12th month
				

Modification Type:MajorLast Reviewed:11/15/2004
Keywords:kbinfo KB76287