Download presentation
Presentation is loading. Please wait.
Published byIndra Widjaja Modified over 6 years ago
1
EXAMPLE Emp table: SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20
25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: 2019/2/22
2
EXAMPLE Select * From Emp Where salary=30,000 Emp table: SS# Name Age
dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select * From Emp Where salary=30,000 2019/2/22
3
EXAMPLE Select * From Emp Where salary=30,000 Emp table: SS# Name Age
dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select * From Emp Where salary=30,000 SS# Name Age Salary dno 4 Kathy 30 30000 5 2019/2/22
4
EXAMPLE Select * From Emp Where age > 22 Emp table: SS# Name Age
Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select * From Emp Where age > 22 2019/2/22
5
EXAMPLE Select * From Emp Where age > 22 Emp table: SS# Name Age
Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select * From Emp Where age > 22 SS# Name Age Salary dno 1 Joe 24 20000 2 4 Kathy 30 30000 5 2019/2/22
6
EXAMPLE Emp table: SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20
25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: 2019/2/22
7
EXAMPLE Emp table: Select age From Emp SS# Name Age Salary dno 1 Joe
24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select age From Emp Age 24 20 22 30 4 2019/2/22
8
EXAMPLE Emp table: Select name, age From Emp Where Salary = 4000 SS#
dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select name, age From Emp Where Salary = 4000 2019/2/22
9
EXAMPLE Emp table: Select name, age From Emp Where Salary = 4000 SS#
dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select name, age From Emp Where Salary = 4000 SS# Name Age Salary dno 5 Shideh 4 4000 1 2019/2/22
10
EXAMPLE Emp table: Select name, age From Emp Where Salary = 4000 SS#
dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select name, age From Emp Where Salary = 4000 Name Age Shideh 4 2019/2/22
11
Join clause Example: Emp table: Dept table: SS# Name age salary dno
345 John Doe 23 25,000 1 943 Jane Java 25 28,000 2 876 Joe SQL 22 32,000 dno dname floor mgrSS# 1 Toy 345 2 Shoe 943 2019/2/22
12
Join clause Select * From Emp e, Dept d Where e.dno = d.dno 2019/2/22
13
Join clause Select * From Emp e, Dept d Where e.dno = d.dno SS# Name
age salary e.dno d.dno dname floor mgrSS# 345 John Doe 23 25,000 1 Toy 876 Joe SQL 22 32,000 943 Jane Java 25 28,000 2 Shoe 2019/2/22
14
EXAMPLE JOIN Select * From Emp e, Dept d Where e.dno = d.dno EMP Dept
SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Select * From Emp e, Dept d Where e.dno = d.dno dno dname floor mgrss# 1 Toy 5 2 Shoe EMP Dept 2019/2/22
15
EXAMPLE JOIN Select * From Emp e, Dept d Where e.dno = d.dno EMP Dept
SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Select * From Emp e, Dept d Where e.dno = d.dno dno dname floor mgrss# 1 Toy 5 2 Shoe EMP Dept SS# Name Age Salary e.dno d.dno dname floor mgrss# 1 Joe 24 20000 2 Shoe Mary 20 25000 Toy 5 3 Bob 22 27000 4 Kathy 30 30000 Shideh 4000 2019/2/22
16
EXAMPLE SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000
Shideh 4 40000 Kathy 15 32000 2019/2/22
17
EXAMPLE SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000
Shideh 4 40000 Kathy 15 32000 Select e.name From Emp e, Emp Mgr Where e.mgrSS# = Mgr.SS# and e.salary > Mgr.salary 2019/2/22
18
EXAMPLE EXECUTION SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob
23 25000 3 Shideh 4 40000 Kathy 15 32000 Select e.name From Emp e, Emp Mgr Where e.mgrSS# = Mgr.SS# and e.salary > Mgr.salary e.SS# e.Name e.Age e.Salary e.mgrSS# Mgr.SS# Mgr.Name Mgr.Age Mgr.Salary Mgr.mgrSS# 2 Bob 23 25000 1 Joe 30 30000 Null 3 Shideh 4 40000 Kathy 15 32000 2019/2/22
19
EXAMPLE SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000
Shideh 4 40000 Kathy 15 32000 Select e.name From Emp e, Emp Mgr Where e.mgrSS# = Mgr.SS# and e.salary > Mgr.salary e.SS# e.Name e.Age e.Salary e.mgrSS# Mgr.SS# Mgr.Name Mgr.Age Mgr.Salary Mgr.mgrSS# 3 Shideh 4 40000 1 Joe 30 30000 Null Kathy 15 32000 2019/2/22
20
EXAMPLE SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000
Shideh 4 40000 Kathy 15 32000 Select e.name From Emp e, Emp Mgr Where e.mgrSS# = Mgr.SS# and e.salary > Mgr.salary e.Name Shideh Kathy 2019/2/22
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.