In addition to the basic comparison predicates (=, >, <, and so on), a search condition can contain any of the predicates BETWEEN, IN, EXISTS, IS NULL, and LIKE.
A search condition can include a scalar fullselect.
For character, or UCS-2 or UTF-16 graphic column predicates, the sort sequence is applied to the operands before evaluation of the predicates for BETWEEN, IN, EXISTS, and LIKE clauses.
You can also perform multiple search conditions.
… WHERE HIREDATE BETWEEN '1987-01-01' AND '1987-12-31'
The BETWEEN keyword is inclusive. A more complex, but explicit, search condition that produces the same result is:
… WHERE HIREDATE >= '1987-01-01' AND HIREDATE <= '1987-12-31'
… WHERE WORKDEPT IN ('A00', 'C01', 'E21')
EXISTS (SELECT * FROM EMPLOYEE WHERE SALARY > 60000)
… WHERE EMPLOYEE.PHONE IS NULL
Use the underline character or percent sign either when you do not know or do not care about all the characters of the column's value. For example, to find out which employees live in Minneapolis, you can specify:
… WHERE ADDRESS LIKE '%MINNEAPOLIS%'
SQL returns any row with the string MINNEAPOLIS in the ADDRESS column, no matter where the string occurs.
In another example, to list the towns whose names begin with 'SAN', you can specify:
… WHERE TOWN LIKE 'SAN%'
If you want to find any addresses where the street name isn't in your master street name list, you can use an expression in the LIKE expression. In this example, the STREET column in the table is assumed to be upper case.
… WHERE UCASE (:address_variable) NOT LIKE '%'||STREET||'%'
If you want to search for a character string that contains either the underscore or percent character, use the ESCAPE clause to specify an escape character. For example, to see all businesses that have a percent in their name, you can specify:
… WHERE BUSINESS_NAME LIKE '%@%%' ESCAPE '@'The first and last percent characters in the LIKE string are interpreted as the normal LIKE percent characters. The combination '@%' is taken as the actual percent character.