Data Manipulation Language - SELECT Statement

This statement is used for retrieving the data from a specific table. It is also known as Data Retrieval Statement.

Syntax:

SELECT {*/ columns list} FROM TABLENAME

In the above syntax the symbol '*' displays all columns and their corresponding rows and the 'columns list' displays specific columns and their corresponding rows.

Example:

SELECT * FROM EMP;

The above statement displays all columns and their corresponding rows from EMP table it means whole EMP table will be displayed.

WHERE CLAUSE: This clause used for evaluating a condition on a specific column of a specific table. It is associated with SELECT, UPDATE, DELETE statements.

Syntax:

SELECT {*/Columns list} FROM TABLENAME [WHERE Condition]

Example:

Write a Query to select employ details who are working under 10th department

SELECT * FROM EMP WHERE DEPTNO=10

Example:

Write a Query to select employ details who are earning salaries between 5000 and 25000

SELECT * FROM EMP WHERE SAL>5000 AND SAL<25000

Example:

Write a Query to select employ details whose employ number is 22

SELECT * FROM EMP WHERE DEPTNO IS NULL

Note:

In the above example we used a special operator called IS operator, which used to compare NULL VALUES.
Share/Bookmark

No comments: