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

SQL Module 3

The document outlines tasks for a module assignment involving joins and updates in SQL. It includes: 1) Creating an Orders table with order details and customer ID, 2) Performing an inner join between Orders and Customers tables on customer ID, 3) Performing left and right joins on the tables, and 4) Updating the amount to 100 for orders where customer ID is 3. SQL queries are provided to implement the table structures and joins, as well as the update statement.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views

SQL Module 3

The document outlines tasks for a module assignment involving joins and updates in SQL. It includes: 1) Creating an Orders table with order details and customer ID, 2) Performing an inner join between Orders and Customers tables on customer ID, 3) Performing left and right joins on the tables, and 4) Updating the amount to 100 for orders where customer ID is 3. SQL queries are provided to implement the table structures and joins, as well as the update statement.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Module-3 Assignment

Problem Statement:
You have successfully cleared the 2nd semester. In your 3rd semester you will work with joins and update
statement

Tasks to be done:

1. Create an ‘Orders’ table which comprises of these columns – ‘order_id’, ‘order_date’, ‘amount’,
‘customer_id’

2. Make an inner join on ‘Customer’ & ‘Order’ tables on the ‘customer_id’ column

3. Make left and right joins on ‘Customer’ & ‘Order’ tables on the ‘customer_id’ column

4. Update the ‘Orders’ table, set the amount to be 100 where ‘customer_id’ is 3

create table Orders


(order_id int, order_date date, amount int,
customer_id int);
insert into Orders (order_id , order_date , amount ,
customer_id )
values(101, getdate(), 50000, 1);
insert into Orders (order_id , order_date , amount ,
customer_id )
values(102, getdate(), 80000, 2);
insert into Orders (order_id , order_date , amount ,
customer_id )
values(103, getdate(),25000, 3);
insert into Orders (order_id , order_date , amount ,
customer_id )
values(104, getdate(), 45000, 4);
select* from Orders
select* from Customers
--1
select Orders.customer_id
from Orders
inner join Customers on Orders.customer_id = Customers.customer_id;
--2
select Orders.customer_id
from Orders
left join Customers on Orders.customer_id = Customers.customer_id;
--3
select Orders.customer_id
from Orders
right join Customers on Orders.customer_id = Customers.customer_id;
--4
UPDATE Orders
SET amount = 100
WHERE customer_id IN (3)
select* from Orders

You might also like