| Oracle8i SQL Reference Release 2 (8.1.6) A76989-01 |
|
Expressions, Conditions, and Queries, 3 of 4
A condition specifies a combination of one or more expressions and logical operators that evaluates to either TRUE, FALSE, or unknown. You must use this syntax whenever condition appears in SQL statements in Chapter 7, "SQL Statements".
You can use a condition in the WHERE clause of these statements:
You can use a condition in any of these clauses of the SELECT statement:
A condition could be said to be of the "logical" datatype, although Oracle does not formally support such a datatype.
The following simple condition always evaluates to TRUE:
1 = 1
The following more complex condition adds the SAL value to the COMM value (substituting the value 0 for null) and determines whether the sum is greater than the number constant 2500:
NVL(sal, 0) + NVL(comm, 0) > 2500
Logical operators can combine multiple conditions into a single condition. For example, you can use the AND operator to combine two conditions:
(1 = 1) AND (5 < 7)
Here are some valid conditions:
name = 'SMITH' emp.deptno = dept.deptno hiredate > '01-JAN-88' job IN ('PRESIDENT', 'CLERK', 'ANALYST') sal BETWEEN 500 AND 1000 comm IS NULL AND sal = 2000
Conditions can have several forms, as shown in the following syntax. The description of each statement in Chapter 7, "SQL Statements", documents the restrictions on the conditions in the statement. The sections that follow describe the various forms of conditions.
condition::=
A simple comparison condition specifies a comparison with expressions or subquery results.
simple_comparison_condition::=
For information on comparison operators, see "Comparison Operators".
A group comparison condition specifies a comparison with any or all members in a list or subquery.
group_comparison_condition::=
A membership condition tests for membership in a list or subquery.
membership_condition::=
A range condition tests for inclusion in a range.
range_condition::=
A NULL condition tests for nulls.
NULL_condition::=
An EXISTS condition tests for existence of rows in a subquery.
EXISTS_condition::=
A LIKE condition specifies a test involving pattern matching.
LIKE_condition::=
A compound condition specifies a combination of other conditions.
compound_condition::=
|
|
![]() Copyright © 1999 Oracle Corporation. All Rights Reserved. |
|