forked from mysrain/oracle-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathouter-join.sql
More file actions
31 lines (25 loc) · 881 Bytes
/
Copy pathouter-join.sql
File metadata and controls
31 lines (25 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## test outer join
drop table product;
create table product (id number, prod_name varchar2(20));
insert into product values (2, 'desk');
insert into product values (3, 'computer');
insert into product values (1, 'chair');
drop table myorder;
create table myorder (id number, prod_id number);
insert into myorder values (101, 1);
insert into myorder values (102, 2);
insert into myorder values (103, 2);
insert into myorder values (104, 4);
drop table orderline;
create table orderline (id number, order_id number, prod_id number);
insert into orderline values (10001, 101, 1);
insert into orderline values (10002, 102, 2);
commit;
select a.*, b.*, c.* from
product a
left join myorder b on a.id = b.prod_id
left join orderline c on a.id = c.prod_id;
select a.*, b.*, c.* from
product a
left join myorder b on a.id = b.prod_id
left join orderline c on b.id = c.order_id;