Combining Conditions when AND Has Precedence
To combine conditions with AND, you put the conditions in the same column of the Grid pane. To combine conditions with OR, you put the first one in the Criteria column and additional conditions into an Or ... column.
For example, imagine that you want to find either employees who have been with the company for more than five years in lower-level jobs or employees with middle-level jobs regardless of their hire date. This query requires three conditions, two of them linked with AND:
- Employees with a hire date earlier than five years ago and with a job level of 100
-or-
- Employees with a job level of 200
The following procedure illustrates how to create this type of query in the Grid pane.
To combine conditions when AND has precedence
- In the Grid pane, add the data columns you want to search. If you want to search the same column using two or more conditions linked with AND, you must add the data column name to the grid once for each value you want to search.
- In the Criteria column, enter all the conditions that you want to link with AND. For example, to link conditions with AND that search the
hire_date
andjob_lvl
columns, enter values as shown here:
These grid entries produce the following WHERE clause in the statement in the SQL pane:
WHERE (hire_date < '01/01/91') AND
(job_lvl = 100)
- In the Or ... grid column, enter conditions that you want to link with OR. For example, to add a condition that searches for another value in the
job_lvl
column, enter an additional value as shown here:
Adding a value in the Or ... column adds another condition to the WHERE clause in the statement in the SQL pane:
WHERE (hire_date < '01/01/91' ) AND
(job_lvl = 100) OR
(job_lvl = 200)
See Also
Combining Conditions when OR Has Precedence | Combining Search Conditions | Creating an Expression | Entering Search Values | Specifying Search Criteria