create table customer(cust id int primary key,cust_nm varchar(20) not null,phoneno
varchar(20) unique);
create table order(oid int,odt date,status varchar(20),amount int , custno int
primary key); #addding foreign key at many side(order) thats take the references of customer table(cust_id)
alter table order add foreign key(custno) references customer(cust_id);
#inserting record in customer table
insert into customer values(1,"A",90909090),(2,"B",80808080),(3,"C",707070770),
(4,"D",606060660),(5,"E",505050505);
#inserting record in Order table
insert into order values(101,'2020-11-08','delivered',1000,3),(102,'2020-11-09','on
the way',750,1),(103,'2020-11-11','delivered',1000,2),(104,'2020-11-09','on the way',2000,2),(105,'2020-11-10','delivered',1000,1),(106,'2020-11- 08','delivered',1000,4);
#show the record using order and customer query combine
select c.cust_id,c.name,o.otd from customer c,orders o;
Q1. show custid,name whose order_dt is 2020-11-09
select c.cust_id,c.name,o.odt from customer c,orders o where odt='2020-11-09';
Q2. show oid and custname whose custid is same.
select c.cust_id,c.name,o.oid from customer c,orders o where c.cust_id=o.custno;
Q3.show the custname whose status is delivered
select c.name,o.oid from customer c,orders o where status="delivered";
Q4. give the discount 20% on amount for the customer who order in month of november and accordingly add that amount in oreder table
update orders set amount=amount-(0.2*amount) where odt="2020-11-DD";
OR update orders set amount=amount-(0.2*amount) where odt="2020-11-09";