Data Query Language(DQL)


To retrieve the data from the table according to the user's instruction is called as query. The select statement can be used to retrieve information from a database. The select statement can be used for:


Select * from table;

Where select identifies which columns
From identifies which table
Table specifies the table from which the data has to retrieve.

Select * from dept;

The above statement will retrieve all the records of dept table.

Select dept-id, dept-name, manager-id
From dept;

The above statements will retrieve the dept-id, dept-name, manager-id column from dept table.

Using arithmetic expression in select statement:

Sometimes you may need to modify the way in which data is displayed or perform calculations. All these operations are possible using arithmetic expression. An arithmetic expression can contain column names, constant numeric values, and arithmetic operator. Some arithmetic operators are given below:

Operator Description
+ add
- subtract
* multiplication
/ division


Select emp-name, emp-sal, emp-sal+3000
From employee;

The above example will show emp-name, emp-sal and their increased salary, which is Rs. 3000/- more from the actual salary.

Uses of alias in select statement:

Whenever oracle server returns the result of a query normally it uses the name of the selected column heading. This heading may not be descriptive hence it may be difficult to understand. You can change the column heading by using a column alias. By default, alias headings appear in uppercase. If the alias contains spaces or special characters(such as # or $), or is case sensitive, enclose the alias in double quotation marks( " " ).


Select emp-name AS EMP-NAME
From employee;

In the above example the query will return that the column heading emp-name as EMP-NAME.

Concatenation operator:

A concatenation operator :

For example,

Select last_name || job_id AS "Emp"
From employee ;

In this example, last_name and job_id are concatenated, and they are given the alias Employee. It is pointed that the employee last name and job code are combined to make a single output column.

Some operators


If you want to display rows based on range of a value in that case the between....and...operator is used.


Select emp-name, emp-salary
From employee
Where emp-salary between 12000 and 25000;

In the above example the query will return all the value of emp-name and emp-salary where emp-salary falls between 12000 and 25000.
Note: the between....and....operator includes the lower limit as well as upper limit.

In operator:

The in operator can be used in a situation where you have to make a search based on a list of values.


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved