Lab Tasks-13
Lab Tasks-13
ID: F2022065243
Section: W4
Customers Table
CustomerI First Name Second Name Email Password
D
1 Ali Ahmed [email protected] Pass1234
2 Hamza Ali [email protected] Qwer1234
3 Awais Saeed [email protected] Awa678
4 zuhaib shahid [email protected] shah234
5 zain Ali [email protected] Ali123
Categories Table
CategoryI CategoryName
D
1 Portable device
2 Mobile
3 Laptop
Products Table
ProductID ProductName Price CategoryID
1 HP Elitebook 70000 3
2 HP Pavilion 90000 3
3 Samsung A32 40000 2
4 USB 3.2 Gen 1 2000 1
Order Table
OrderID CustomerID Order Date
1 1 01-01-2023
2 1 12-3-2022
3 2 13-12-2022
4 3 07-05-2023
5 1 09-09-2021
6 2 02-06-2023
7 2 04-06-2019
8 4 01-02-2023
Task 01:
Create a stored procedure that retrieves information about customers and their associated
orders ID and order Date
Task 02:
Create a store procedure that fetches the details of products where productid = 1.
SOLUTION:
DELIMITER ;
CALL GetCustomerOrdersInfo();
DELIMITER //
create procedure ProductDetails(IN ID int)
begin
select *
from Products
where ProductID=ID;
end //
DELIMITER ;
Task 03:
Create a view of customer order details where each customer can only see their own order
details.
Solution:
DELIMITER ;
CREATE VIEW CustomerOrder
AS
SELECT
Customers.CustomerID,Customers.FirstName,Customers.SecondName,Customers.Email,Cus
tomers.Password,Orders.OrderID,Orders.OrderDate
FROM Customers
JOIN Orders ON Customers.CustomerID=Orders.CustomerID;
Task 04:
Create a view that can provide information about the customers and their associated orders.
SOLUTION: