You are on page 1of 3

Practical No.

Aim: To apply BETWEEN…AND, NOT BETWEEN, IN, NOT IN, IS NULL, IS


NOT NULL clause on created database.

Theory:

Between…AND:

The between operator allows the selection of rows that contain values within a
specified lower and upper limit. The range coded after the word between is inclusive.
You must specify the lower limit first.
Syntax:

Select * from <tablename> where columnname between (columnname value) and


(columnname value);

Ex:- Table used


SQL> select * from computer;

CNAME CSIZE CCOLOR CPRICE


---------- ---------- ---------- ----------
accer 32 black 30000
hcl 42 pink 35000

SQL> select * from computer where cprice between(30000) and (32000);

CNAME CSIZE CCOLOR CPRICE


---------- ---------- ---------- ----------
accer 32 black 30000

Not Between:

Not between works just opposite of between…and. It allows the selection of rows that
does not contain values within a specified lower and upper limit.
Syntax:

Select columnname from <tablename> where columnname not between (columnname


value) and (columnname value);

Ex:- SQL> select * from computer where cprice not between (30000) and (32000);

CNAME CSIZE CCOLOR CPRICE


---------- ---------- ---------- ----------
hcl 42 pink 35000

Page 1 of 3
IN:

To test for values in a specified set of values, use the IN condition. The IN condition
is also known as the membership condition. The IN condition can be used with any
data type.

Syntax:
Select columnname from <tablename> where columnname in (columnname value,
columnname value);

Ex:- SQL> select * from computer where cprice in(30000, 35000);

CNAME CSIZE CCOLOR CPRICE


---------- ---------- ---------- ----------
accer 32 black 30000
hcl 42 pink 35000

NOT IN:
The not in condition is the opposite of in condition. This will select all the rows
whose value does not match the values in the list.

Syntax:
Select columnname from < tablename> where columnname no in (columnname value,
columnname value);

Ex:- SQL> select * from computer where cprice not in(35000, 40000);

CNAME CSIZE CCOLOR CPRICE


---------- ---------- ---------- ----------
accer 32 black 30000

IS NULL/IS NOT NULL:

The null condition includes the IS NULL condition and the IS NOT NULL condition.
The IS NULL condition tests for nulls. A null means the value is unavailable,
unassigned unknown or inapplicable. Therefore we cannot test NULL values with =
because a null cannot be equal or unequal to any value. The IS NULL condition
retrieve all the values in a particular column those are null and is not null retrieves all
the values in a particular column those are not null.

Syntax:

Select * from <tablename> where columnname is null;

Ex:- SQL> select * from computer where cprice is null;

no rows selected

Page 2 of 3
Select * from <tablename> where columnname is not null;

Ex:- SQL> select * from computer where cprice is not null;

CNAME CSIZE CCOLOR CPRICE


---------- ---------- ---------- ----------
accer 32 black 30000
hcl 42 pink 35000

Page 3 of 3

You might also like