Sunday, October 6, 2013

DATA QUERY LANGUAGE

The commands that are used to retrieve the data from db are collectively called as Data Query Language.

As select statements is used to retrieve data from db, select statement is called as a query.

Select statement that has the following syntax

Syntax
Select */ collist  from  <TableName>

Dept Table.(Deptno-->pk)


Emp Table(Empno-PK    , Deptno--fk)







 Display the details of all the Depts available in the company.
 select * from Dept

 Display Ename, Empno,job and salary of all the Employees.


select empno,ename,job,sal from emp

Where Clause

It is used to specify the conditions based on which the rows retrieved by the select statement will be filtered.
When you write where clause in the select statement then, it will return only the rows that satisfy the given condition.

Syntax:
Select * | <collist> from <table name> where <conditions>



Find the employees working in dept 20
select *from emp where deptno=20

Find the employees whose job is Manager
select *from emp where job='manager'



To get the manager and clerks list


Select *from emp where job in('manager','clerk')
select *from emp where job ='manager' or job='clerk'


Find the employees whose salary is in the range of 2000 and 4000
select *from emp where sal  between 2000 and 4000
select *from emp where sal>2000 and sal <=4000

Find the employees who are working as Manager in dept no 30
select *from emp where job='manager' and deptno=30

Find the employees whose salary is either 800 or 950 or1300
select *from emp where sal=800 or sal=950 or sal=1300

Find the employees who are not working as manager
select *from emp where job!='manager' 
select *from emp where job <> 'manager'
select *from emp where not job='manager'


Find the software for which development cost was not recover.
select * from software where scost*SOLD<DCOST

No comments:

Post a Comment

Thank you for visiting my blog

Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...