Specifying Multiple Search Conditions for Multiple Columns

See Also

You can expand or narrow the scope of your query by including several data columns as part of your search condition. For example, you might want to:

Note   Oracle allows you to use distributive syntax for specifying multiple criteria. For details, see Query Designer Considerations for Oracle Databases.

To create a query that searches for values in either of two (or more) columns, you specify an OR condition. To create a query that must meet all conditions in two (or more) columns, you specify an AND condition.

Note   If you are creating queries that include combinations of AND and OR clauses, you must be aware of how the query is interpreted when you execute it. For details, see Combining Search Conditions.

Specifying an OR Condition

To create multiple conditions linked with OR, you put each separate condition in a different column of the Grid pane.

To specify an OR condition for two different columns

  1. In the Grid pane, add the columns you want to search. For details, see Adding Columns.

  2. In the Criteria column for the first column to search, specify the first condition. For details, see Specifying Search Conditions.

  3. In the Or … column for the second data column to search, specify the second condition, leaving the Criteria column blank.

    The Query Designer creates a WHERE clause that contains an OR condition such as the following:

    SELECT job_lvl, hire_date
    FROM employee
    WHERE (job_lvl >= 200) OR 
      (hire_date < '01/01/90')
    
  4. Repeat Steps 3 and 4 for each additional condition you want to add. Use a different Or … column for each new condition.

Specifying an AND Condition

To search different data columns using conditions linked with AND, you put all the conditions in the Criteria column of the grid.

To specify an AND condition for two different columns

  1. In the Grid pane, add the columns you want to search.

  2. In the Criteria column for the first data column to search, specify the first condition.

  3. In the Criteria column for the second data column, specify the second condition.

    The Query Designer creates a WHERE clause that contains an AND condition such as the following:

    SELECT pub_id, title
    FROM titles
    WHERE (pub_id = '0877') AND (title LIKE '%Cook%')
    
  4. Repeat Steps 2 and 3 for each additional condition you want to add.