You are on page 1of 5

NAME: VEDANT CHAWARE

BRANCH: I& C
DIV: A
BATCH: B1
ROLL.NO: 13
PRN: 1211041

DBMS ASSIGNMENT NO.8:

CODE AND OUTPUT:


select orders.order_id, customers.cust_nm, orders.order_date from orders inner join customers on
orders.cust_id=customers.cust_id;

ALTER TABLE orders ADD (bill_amount int(50));

UPDATE orders SET bill_amount =8000 WHERE (order_id=10310);

UPDATE orders SET bill_amount =2000 WHERE (order_id=10308);

UPDATE orders SET bill_amount =5000 WHERE (order_id=10309);

UPDATE orders SET bill_amount =3000 WHERE (order_id=10311);


2. Theta Join

select orders.order_id, customers.cust_id, customers.cust_nm, orders.bill_amount from orders join


customers on orders.bill_amount>3000 and orders.cust_id= customers.cust_id;

3.Natural Join

insert into orders values(10312,97,"1996-09-22",4500);

insert into customers values(05,"Steve",989876,"Japan");

UPDATE orders SET cust_id = 3 WHERE (order_id = 10309);

UPDATE orders SET cust_id = 1 WHERE (order_id = 10310);

UPDATE orders SET cust_id = 4 WHERE (order_id = 10311);

UPDATE orders SET cust_id = 2 WHERE (order_id = 10312);


select o.order_id, o.bill_amount, c.cust_nm from orders as o natural join customers as c;

4.Left Join

select orders.order_id, orders.cust_id from orders left outer join customers on


orders.cust_id=customers.cust_id;

5. Right Outer Join

select orders.order_id, orders.cust_id from orders right outer join customers on


orders.cust_id=customers.cust_id;
6.Full Outer Join

select orders.order_id, orders.cust_id from orders full outer join customers on


orders.cust_id=customers.cust_id where cust_id=2;

7.SQL Self Join

select t1.cust_id from orders t1, orders t2 where t1.cust_id=t2.cust_id and t1.order_id<>t2.order_id;

You might also like