There is only one command to retrieve
data back from the table and it is known as “Select”.
Select can be used with different
operators. Following are the different formats of Select command that can be
used:
Ø
Select * from Dept
To Select all columns and all rows from
Dept table
Ø Select Deptno, Dname
from Dept
To Select Column
Deptno and Dname from Dept table
Ø
Select Deptno * 10 as 'Calculated Deptno'
from Dept
This will multiply
Deptno with 10 and the name of the column displayed will be ‘Calculated Deptno’
Ø
Select * from Dept where Deptno=10
To select all rows
where Deptno is equal to 10
Other Examples of Select Query
Ø Select * from Dept where Dname = 'MARKETING'
Ø Select * from Dept where Deptno=10 or Loc = 'BOSTON'
Ø Select * from Dept where Deptno=10 and LOC ='BOSTON'
Ø Select * from Dept where Deptno between 10 and 30
Ø Select * from Dept where Deptno in (10,20)
Ø Select * from Dept where Deptno not in (10,20)
Ø Select * from Dept where Loc is null
Ø Select * from Dept where Loc is not null
Comments