You are on page 1of 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