Thursday 10 March 2016

Select INTO

Selects or copy the data from one table to another.


Select * INTO EMP_DB2 From EMP_DATABASE; 

Copies the data from EMP_DATABASE to EMP_DB2

 

Aliases Name

The name given to the table or column for temporary result set.

Example

Select EMP_Name as Employee_Name From EMP_DATABASE;


Select ABC.EMP_NAME From EMP_DATABASE as ABC;

 

Between Operator

Specifies the range and selects data within it.


Select * From STUDENT_DATBASE
Where Marks BETWEEN 20 AND 40;

NOT keyword can also be used to exclude the range




Select * From STUDENT_DATBASE
Where Marks NOT BETWEEN 20 AND 40;

IN Operator

Multiple values can be specified with the Where clause

Example

Select * From EMP_DATABASE Where EMP_ID in ('AVX550', 'AV2551');

Like Operator

This operator can be use to search for specified pattern from data set.
Example
Select * From EMP_DATABASE Where EMP_Name LIKE 'R%'
Displays the result where Employee name start with R alphabet

Select * From EMP_DATABASE Where EMP_Name LIKE '%R'
Displays the result where Employee name ends with R alphabet

Select * From EMP_DATABASE Where EMP_Name LIKE '%R%'
Displays the result where Employee name contains R alphabet

TOP Clause

Limits the number of Rows in the result set based on criteria or percentage specified


Select TOP 3 * From EMP_DATABASE

Select TOP 20 Percent * From EMP_DATABASE

Delete Statement

Delete statement allows you to delete rows from the existing table.
Example
Delete From EMP_DATABASE
Where EMP_NAME ='Ramneek'
To delete all records
Delete * From EMP_DATBASE (Only Records deleted not Table)