Show TOC

Boolean ExpressionsLocate this document in the navigation structure

The Boolean operators AND, OR and NOT allow combining multiple search conditions to complex Boolean expressions.

The result of the Boolean operations is given in the following tables:

AND

TRUE

FALSE

unknown

TRUE

TRUE

FALSE

unknown

FALSE

FALSE

FALSE

FALSE

unknown

unknown

FALSE

unknown

OR

TRUE

FALSE

unknown

TRUE

TRUE

TRUE

TRUE

FALSE

TRUE

FALSE

unknown

unknown

TRUE

unknown

unknown

NOT

TRUE

FALSE

unknown

 

FALSE

TRUE

unknown

<boolean expression> ::= <boolean term> 
                                       | <search condition> OR <boolean term>.

<boolean term> ::= <boolean factor> 
                             | <boolean term> AND <boolean factor>.

<boolean factor> ::= 
           ( NOT )? ( <predicate> 
                        | '(' <search condition> ')' ).

         

Example

SELECT * FROM employees 
         WHERE employee_name LIKE 'John%' 
            OR NOT ( salary > 50000 
                     AND employee_name = 'Mary Jones')

            

Boolean Operations. The query selects all employees with a name starting with 'John' or with a salary not exceeding 50000 or with a name equal to 'Mary Jones'.

More Information

Search Condition