Database Toolbox    

Retrieving Information That Meets Specified Criteria

Use the Where field in Advanced query options to retrieve only the information that meets criteria you specify. This example uses basic.qry, created and saved in Building, Running, and Saving a Query. It limits the results to those stock numbers greater than 400000 and less than 500000.

  1. Load basic.qry. For instructions, see Using a Saved Query.
  2. In Advanced query options, click Where.

    The Where Clauses dialog box appears.

  1. Select the Fields whose values you want to restrict. For example, select StockNumber.
  2. Use Condition to specify the criteria. For example, specify that the StockNumber be greater than 400000.
    1. Select Relation.
    2. From the drop-down list to the right of Relation, select >.
    3. In the field to the right of the drop-down list, type 400000.

    4. Click Apply.
  3. You can add another condition. First you edit the current clause to add the AND operator to it, and then you provide the new condition.
    1. Select StockNumber > 400000 from Current clauses.
    2. Click Edit (or double-click the StockNumber entry in Current clauses).
    1. For Operator, select AND.
    2. Click Apply.
  4. Add the new condition. For example, specify that StockNumber must also be less than 500000.
    1. From Fields, select StockNumber.
    2. Select Relation from Condition.
    3. From the drop-down list to the right of Relation, select <.
    4. In the field to the right of the drop-down list, type 500000.
    5. Click Apply.
  5. Click OK.

    The Where Clauses dialog box closes. The SQL statement in the Visual Query Builder dialog box reflects the where clause you specified.

  1. Assign a MATLAB workspace variable; for example, A.
  2. Click Execute.

    The results are a 6-by-4 matrix.

  1. To view the results, type A in the Command Window. Compare these to the results for all stock numbers, which is a 10-by-4 matrix (see step 6 in Building and Running a Query).

  2. Select Save from the Query menu and name this query basic_where.qry.

 Retrieving Unique Occurrences Grouping Criteria