0% found this document useful (0 votes)
51 views

'B001' 'Dessie' 'B002' 'Gondar' 'B003' 'Addis Ababa'

The document creates two tables, Branch and PropertyForRent, to store branch and property rental data. It inserts records into each table and then performs various joins between the two tables to relate branches to properties based on city.

Uploaded by

hiwot kebede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

'B001' 'Dessie' 'B002' 'Gondar' 'B003' 'Addis Ababa'

The document creates two tables, Branch and PropertyForRent, to store branch and property rental data. It inserts records into each table and then performs various joins between the two tables to relate branches to properties based on city.

Uploaded by

hiwot kebede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

create database baranchProperty;

use baranchProperty;

create table Branch(


branchNo varchar(50),
Bcity varchar(50)
);
insert into Branch values('B001','Dessie');
insert into Branch values('B002','Gondar');
insert into Branch values('B003','Addis Ababa');

create table PropertyForRent(


PropertyNo varchar(50),
Pcity varchar(50)
);
insert into PropertyForRent values('P001','Bahirdar');
insert into PropertyForRent values('P002','Dessie');
insert into PropertyForRent values('P003','Gondar');
--1
(select Bcity from Branch) union(select Pcity from PropertyForRent);
--2
select b.*,P.*
from Branch b left join PropertyForRent p on b.Bcity=p.Pcity;
--or
select branchNo,Bcity,Pcity,PropertyNo from Branch b left join PropertyForRent p on
b.Bcity=p.Pcity;

--3
select b.*,p.*
from Branch b
right join PropertyForRent p on b.Bcity=p.Pcity;
--or
select branchNo,Bcity,Pcity,PropertyNo from Branch b right join PropertyForRent p on
b.Bcity=p.Pcity;
--4
select branchNo,Bcity,Pcity,PropertyNo from Branch full join PropertyForRent on
Bcity=Pcity;

You might also like