You are on page 1of 9

join

• Q1:-create database customer;


• Q2:-use customer;
• Q3:-create table customer_details(CustomerID
int primary key,CustomerName
varchar(20),ContactName varchar(10),Country
varchar(20));
join
Q4:-
Q5:- insert into customecreate table
oder_details(OrderID int primary
key,CustomerID int,OrderDate date,foreign
key(CustomerID) references
customer_details(CustomerID));r_details
values(1,'Arun','Maria','Germany'),
(2,'Akash','Meena','Mexico'),
(3,'Chandran','Divya','Mexico');
join
Q6:-insert into oder_details values
(10308,2,'5-05-23'),
(10309,'1','6-02-24'),
(10310,3,'5-05-23');
join
Q7:- for inner join
select oder_details.OrderID,
customer_details.CustomerName,
oder_details.OrderDate
from oder_details inner join customer_details
on
oder_details.CustomerID=customer_details.Cu
stomerID
join
Q8:- for joining 3 table
create table Shippers(ShipperID int primary key,
ShipperName varchar(10));

insert into Shippers values(11248,'Federal'),


(11249,'Speedy '),
(11250,'United');
join
Q8:- for joining 3 table
create table Shippers(ShipperID int primary key,
ShipperName varchar(10));

Q9:-insert into Shippers values(11248,'Federal'),


(11249,'Speedy '),
(11250,'United');
join
Q10:- for adding columns and foreinkey

alter table oder_details add ShipperID int,ADD


CONSTRAINT foreign key(ShipperID)
references Shippers(ShipperID);
join
Q11:-
update oder_details set ShipperID=11250 where
OrderID=10310 ;
join
Q12:-
select oder_details.OrderID,
customer_details.CustomerName,
oder_details.OrderDate,
Shippers.ShipperName
from ((oder_details
inner join customer_details on
oder_details.CustomerID=customer_details.CustomerID)
inner join Shippers on
oder_details.ShipperID=Shippers.ShipperID);

You might also like