Follow us: Connect on YouTube Connect on YouTube Connect on YouTube

Pages

Wednesday, 19 July 2017

SQL Between Operator


Between Operator use to pick the values with the specified range.
It will Supports with numbers and data values.
Between includes range limits in output.
Not between excludes range limits from output.


SQL Between Syntax


SELECT column1,column2...
FROM table_name
WHERE column_name BETWEEN value1 AND value2;


Example

The following statement returns employee salary who having 10000 and 20000

SELECT *
  FROM emp
 WHERE sal BETWEEN 10000 AND 20000;


Example


The following statement update employee salary 35% who joined between
'1 -JAN-10' and '31-DEC-10'

UPDATE emp
SET Sal = sal + sal * .35
WHERE hiredate BETWEEN '1 -JAN-10' and '31-DEC-10';



SQL Not Between



SQL NOT Between Syntax




SELECT column1,column2...
FROM table_name
WHERE column_name NOT BETWEEN value1 AND value2;



Example

The following statement returns employee salary who not having 10000 and 20000

SELECT *
  FROM emp
 WHERE sal NOT BETWEEN 10000 AND 20000;



Example


The following statement update employee salary 15% who not joined between
'1 -JAN-10' and '31-DEC-10'

UPDATE emp
SET Sal = sal + sal * .15
WHERE hiredate NOT BETWEEN '1 -JAN-10' and '31-DEC-10';



You May Like                                             
                            SQL IN Operator
                            SQL Like Operator                         
                            SQL is NULL AND is NOT NULL



Share this article :

0 comments:

Post a Comment