0% found this document useful (0 votes)
16 views17 pages

MySql Task 2

Uploaded by

Nithya kalyani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views17 pages

MySql Task 2

Uploaded by

Nithya kalyani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

MySql task 1:

Create a database named: product_management_system:

Table 1: Products

Column Type Length Default Auto Increment

id INT - - YES

productName VARCHAR 100 - -

description TEXT - - -

price DECIMAL 10,2 0.00 -

stockQuantity INT - 0 -

status VARCHAR 10 'active' -

createdDate TIMESTAMP - CURRENT_TIMESTAMP -

 Insert a new product into the Products table. The productName is 'Wireless Mouse',
description is 'High-precision wireless mouse', price is 15.99, and stockQuantity is 100. Set
the status to 'active'.

 "Insert a product into the Products table with only the productName as 'USB Cable' and
price as 5.99."
 "Update the price of the product with id = 1 to 20.99."
 "Update the stockQuantity of the product with productName = 'Laptop Stand' to 50."

 "Change the status of the product with id = 3 to 'inactive'."


 "Delete the product with id = 2 from the Products table."


 "Remove all products from the Products table where the status is 'inactive'."
 "Retrieve all details of the product with id = 1."
 "Find all products where the price is greater than 50."
 "Get a list of all products with status set to 'active'."
 "Retrieve the productName and price for all products where stockQuantity is greater than
0."
Table 2: Categories

Column Type Length Default Auto Increment

id INT - - YES

categoryName VARCHAR 50 - -

description TEXT - - -

status VARCHAR 10 'active' -

createdDate TIMESTAMP - CURRENT_TIMESTAMP -

 "Insert a new category into the Categories table. The categoryName is 'Electronics',
description is 'Devices and gadgets', and the status is 'active'."

 "Insert a category into the Categories table with only the categoryName as 'Furniture'."

 "Update the status of the category with id = 1 to 'inactive'."

 "Update the description of the category with categoryName = 'Home Appliances' to


'Appliances for household use'."

 "Rename the category with id = 2 to 'Outdoor Equipment'."


 "Delete the category with id = 3 from the Categories table."


 "Retrieve all details of the category with id = 1."


 "Find all categories where the status is 'active'."
 "Retrieve the categoryName and description for all categories."
 "Get a list of categories created in the last 30 days."
 "Retrieve all categories where the categoryName contains the word 'Home'."
 "Get a list of all categories where the status is not 'inactive'."
 "Find all categories where the categoryName starts with 'E'."
 "Find all categories where the status is either 'active' or 'pending'."
 "Get all categories created in January or February."
 "Find all categories where the categoryName has 'Appl' in it."
Table 3: Suppliers

Column Type Length Default Auto Increment

id INT - - YES

supplierName VARCHAR 100 - -

contactEmail VARCHAR 100 - -

phone VARCHAR 15 - -

status VARCHAR 10 'active' -

createdDate TIMESTAMP - CURRENT_TIMESTAMP -

 "Insert a new supplier into the Suppliers table. The supplierName is 'Tech Supplies Co',
contactEmail is '[email protected]', phone is '1234567890', and the status is
'active'."

 "Insert a supplier into the Suppliers table with the supplierName as 'Office Depot' and
contactEmail as '[email protected]'."

 "Update the status of the supplier with id = 1 to 'inactive'."


 "Change the phone number of the supplier with supplierName = 'Tech Supplies Co' to
'0987654321'."

 "Update the contactEmail of the supplier with id = 2 to '[email protected]'."


 "Delete the supplier with id = 3 from the Suppliers table."


 "Remove all suppliers from the Suppliers table where the status is 'inactive'."
 Select supplier details by phone number:
"Retrieve all details of the supplier with the phone number '1234567890'."
 Select suppliers where the name contains a keyword:
"Find all suppliers where the supplierName contains the word 'Supply'."
 Select suppliers that do not have a specific status:
"Get a list of all suppliers where the status is not 'inactive'."
 Select suppliers with emails from a specific domain:
"Find all suppliers whose contactEmail ends with '@techsupplies.com'."
 Select suppliers based on a list of specific statuses:
"Retrieve all suppliers where the status is either 'active' or 'pending'."
 Select suppliers created in the last 60 days:
"Get a list of suppliers who were added to the Suppliers table in the last 60 days."
 Select suppliers with a name starting with a specific letter:
"Retrieve all suppliers where the supplierName starts with 'O'."
 Select suppliers based on phone pattern:
"Find all suppliers whose phone number starts with '123'."
Table 4: Customers

Column Type Length Default Auto Increment

id INT - - YES

customerName VARCHAR 100 - -

email VARCHAR 100 - -

phone VARCHAR 15 - -

address VARCHAR 255 - -

status VARCHAR 10 'active' -

createdDate TIMESTAMP - CURRENT_TIMESTAMP -

 "Insert a new customer into the Customers table. The customerName is 'John Doe', email is
'[email protected]', phone is '1234567890', address is '123 Main St, Springfield', and
status is 'active'."

 "Insert a customer into the Customers table with customerName as 'Jane Smith' and email
as '[email protected]'."

 "Update the status of the customer with id = 1 to 'inactive'."


 "Change the phone number of the customer with customerName = 'John Doe' to
'0987654321'."

 "Update the email of the customer with id = 2 to '[email protected]'."


 "Delete the customer with id = 3 from the Customers table."


 "Remove all customers from the Customers table where the status is 'inactive'."
 Select customer details by phone number:
"Retrieve all details of the customer with the phone number '1234567890'."
 Select customers where the name contains a keyword:
"Find all customers where the customerName contains the word 'Smith'."
 Select customers that do not have a specific status:
"Get a list of all customers where the status is not 'inactive'."
 Select customers with emails from a specific domain:
"Find all customers whose email ends with '@example.com'."
 Select customers based on a list of specific statuses:
"Retrieve all customers where the status is either 'active' or 'pending'."
 Select customers created in the last 90 days:
"Get a list of customers who were added to the Customers table in the last 90 days."
 Select customers with a name starting with a specific letter:
"Retrieve all customers where the customerName starts with 'J'."
Table 5: Orders

Column Type Length Default Auto Increment

id INT - - YES

orderDate TIMESTAMP - CURRENT_TIMESTAMP -

orderTotal DECIMAL 10,2 0.00 -

status VARCHAR 10 'active' -

 "Insert a new order into the Orders table. The orderTotal is 150.75 and the status is 'active'."

 "Insert an order with an orderTotal of 200.50."


 "Update the status of the order with id = 1 to 'completed'."


 "Change the orderTotal of the order with id = 2 to 175.00."


 "Delete the order with id = 3 from the Orders table."


 "Remove all orders from the Orders table where the status is 'inactive'."
 Select order details by specific date:
"Retrieve all orders placed on '2023-12-15'."
 Select orders with a total greater than a specific amount:
"Find all orders where the orderTotal is greater than 100.00."

 Select orders that do not have a specific status:


"Get a list of all orders where the status is not 'completed'."
 Select orders with a specific status:
"Retrieve all orders where the status is 'pending'."
 Select orders created in the last 30 days:
"Get a list of orders placed in the last 30 days."
 Select orders with total between a specific range:
"Find all orders with orderTotal between 50.00 and 200.00."

 Select orders with specific statuses:


"Retrieve all orders where the status is either 'active' or 'completed'."

You might also like