Comparison Operators
Comparison Operators list:
Operator | Description |
---|---|
= | Equal |
<> or != | Not equal |
< | Less than |
> | Greater than |
<= | Less than or equal to |
>= | Greater than or equal to |
ANY | Compares one value with any value in a list |
SOME | Identical to the ANY operator |
ALL | Compares one value with all values in a list |
Example:
CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
ENAME VARCHAR2(10),
HIREDATE DATE);
INSERT INTO EMP VALUES (1, 'SMITH', TO_DATE('17-DEC-1980', 'DD-MON-YYYY'));
INSERT INTO EMP VALUES (2, 'ALLEN', TO_DATE('20-FEB-1981', 'DD-MON-YYYY'));
INSERT INTO EMP VALUES (3, 'WARD', TO_DATE('22-FEB-1981', 'DD-MON-YYYY'));
INSERT INTO EMP VALUES (4, 'JONES', TO_DATE('2-APR-1981', 'DD-MON-YYYY'));
INSERT INTO EMP VALUES (5, 'MARTIN',TO_DATE('28-SEP-1981', 'DD-MON-YYYY'));
SQL> SELECT *
2 FROM emp
3 WHERE empno > 2;
EMPNO ENAME HIREDATE
---------- ---------- ---------
3 WARD 22-FEB-81
4 JONES 02-APR-81
5 MARTIN 28-SEP-81
SQL>
SQL> SELECT *
2 FROM emp
3 WHERE empno <> 2;
EMPNO ENAME HIREDATE
---------- ---------- ---------
1 SMITH 17-DEC-80
3 WARD 22-FEB-81
4 JONES 02-APR-81
5 MARTIN 28-SEP-81
SQL>