skip to main content
Supported SQL functionality : SQL expressions : Operators : Logical operators
  

Try DataDirect Drivers Now
Logical operators
A logical operator combines the results of two component conditions to produce a single result or to invert the result of a single condition. The following table lists the supported logical operators.
Table 20. Logical operators
Operator
Purpose
Example
NOT
Returns TRUE if the following condition is FALSE. Returns FALSE if it is TRUE. If it is UNKNOWN, it remains UNKNOWN.
SELECT * FROM emp WHERE NOT (job IS NULL)
SELECT * FROM emp WHERE NOT (sal BETWEEN 1000 AND 2000)
AND
Returns TRUE if both component conditions are TRUE. Returns FALSE if either is FALSE; otherwise, returns UNKNOWN.
SELECT * FROM emp WHERE job = 'CLERK' AND deptno = 10
OR
Returns TRUE if either component condition is TRUE. Returns FALSE if both are FALSE; otherwise, returns UNKNOWN.
SELECT * FROM emp WHERE job = 'CLERK' OR deptno = 10

Example

In the Where clause of the following Select statement, the AND logical operator is used to ensure that managers earning more than $1000 a month are returned in the result:
SELECT * FROM emp WHERE jobtitle = manager AND sal > 1000