Presentation is loading. Please wait.

Presentation is loading. Please wait.

Topic - DML - Select statement

Similar presentations


Presentation on theme: "Topic - DML - Select statement"— Presentation transcript:

1 Topic - DML - Select statement
Objective: 1) Understand the purpose of ‘select’ command and able to write query using ‘SELECT’ 2) Understand and use relational and logical operators in ‘select’ statement

2 DML - Select statement Purpose - > Used to get data from database.
Syntax Select <attribute list separated with comma> from <table name> where <condition>;

3 Select clause Ex: 1)Select * from employee;
OUTPUT-1 ID NAME SALARY 1 ARUN 6000 2 VARUN 8000 3 ALI 9000 4 GEORGE 12000 5 MOHD Ex: 1)Select * from employee; 2)Select id,name from employee; TABLE - EMPLOYEE OUTPUT-2 ID NAME SALARY 1 ARUN 6000 2 VARUN 8000 3 ALI 9000 4 GEORGE 12000 5 MOHD ID NAME 1 ARUN 2 VARUN 3 ALI 4 GEORGE 5 MOHD

4 Ex: 1) Select salary from employee;
Select clause TABLE - EMPLOYEE OUTPUT -1 OUTPUT -2 ID NAME SALARY 1 ARUN 6000 2 VARUN 8000 3 ALI 9000 4 GEORGE 12000 5 MOHD SALARY 6000 8000 9000 12000 SALARY 6000 8000 9000 12000 Ex: 1) Select salary from employee; 2) Select distinct salary from employee;

5 Operators used in ‘Where ‘clause
1. Relational Operators > >= < < = = <> Greater than Greater than or equal to Less than Less than or equal to Equal to Not equal to

6 Relational Operators used in ‘Where ‘clause
Output-3 TABLE - EMPLOYEE Output-1 Output-2 NAME ARUN ALI GEORGE ID NAME SALARY 1 ARUN 6000 2 VARUN 8000 3 ALI 9000 4 GEORGE 12000 5 MOHD ID NAME 1 ARUN ID NAME SALARY 3 ALI 9000 4 GEORGE 12000 Ex. 1) Select id,name from employee where id=1; 2) Select * from employee where salary>8000; 3) Select name from employee where salary < >8000;

7 Logical Operators used in ‘Where ‘clause
AND OR NOT Used when both the conditions should be satisfied Used when any one of the conditions should be satisfied Used to consider the condition opposite to the given one.

8 Logical Operators used in ‘Where ‘clause
Output-3 TABLE - EMPLOYEE Output-1 Output-2 ID NAME SALARY 1 ARUN 6000 2 VARUN 8000 3 ALI 9000 4 GEORGE 12000 5 MOHD ID NAME 3 ALI ID NAME 1 ARUN 4 GEORGE ID NAME 3 ALI 4 GEORGE Ex. 1) Select id,name from employee where salary>8000 AND salary<12000; 2) Select id,name from employee where salary>9000 OR salary<8000; 3) Select id,name from employee where NOT salary<9000;


Download ppt "Topic - DML - Select statement"

Similar presentations


Ads by Google