0% found this document useful (0 votes)
8 views

SQL Tutorial (Chap11)

sql basics

Uploaded by

jaggu011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

SQL Tutorial (Chap11)

sql basics

Uploaded by

jaggu011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

 Chapter 11: Relational Negation Operators

SQL Tutorial - NOT LIKE Operator

Display the employees whose name is not ends with ‘S’ in EMP table
SQL> SELECT *FROM emp WHERE ename NOT LIKE ‘%S’;

Display the employees whose names are not having second letter as ‘L’ in EMP table
SQL>SELECT *FROM emp WHERE ename NOT LIKE ‘_L%’;
Display the employees whose names are not start with ‘S’ in EMP table.
SQL>SELECT *FROM emp WHERE ename NOT LIKE ‘S%’;

Display the employees whose names are second letter start with ‘R’ from ending.
SQL>SELECT *FROM emp WHERE ename LIKE ‘%R_’;

Display the names in EMP table whose names having ‘LL’.


SQL> SELECT *FROM emp WHERE ename LIKE ‘%LL%’;
SQL Tutorial - Not Equals to ( != / ^= /
<> ) Operator

Relational Operator Not Equals to

Not equals to ( != or ^= or <> )


This operator is used for inequality test.

Examples:
Display the details of employees whose salary is not equals to 2000.

SELECT * FROM emp WHERE sal != 2000;

SELECT * FROM emp WHERE sal ^= 2000;


SELECT * FROM emp WHERE sal <> 2000;

SQL Tutorial - NOT IN Operator

NOT IN:
‘not in’ operator is quite opposite to ‘IN’ clause.
SQL> SELECT *FROM emp WHERE empno NOT IN (7125, 7369, 7782);

Inside DML statements:


SQL> UPDATE emp SET sal=sal+200 WHERE ename NOT IN (‘SMITH’,’ALLEN’,’WARD’);

SQL> DELETE FROM emp WHERE hiredate NOT IN (‘22-DEC-82’,’ 17-NOV-81’);

SQL Tutorial - NOT BETWEEN Operator

NOT BETWEEN
 Returns true if value specified is not within the specified range.
 Supports with numbers and date values.
 Not between is an exclusive operator which eliminates range limits from Output.

Example:-
SQL> SELECT *FROM emp WHERE sal NOT BETWEEN 2000 AND 3000;
Lower bound – ‘value ‘must be lower when compare to ‘upper bound ‘value
Upper bound- ‘value’ must be higher when compare to ‘lower bound ‘value

SQL Tutorial - IS NOT NULL Operator

IS NOT NULL:-
-Use to search for NOT NULL values in the given input

-Supports with all types of data


Let’s fetch all employees whose commission is NOT NULL.

NOT NULL Example :-


SQL> SELECT *FROM emp WHERE comm IS NOT NULL;

Original existing data in the ‘emp’ table is

You might also like