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

Ip-class12 -Practical File -Database Query Using Mysql.docx

The document provides instructions for creating and managing a MySQL database named 'company' with a table 'products' containing various product details. It includes SQL queries for creating the table, inserting records, displaying data based on specific conditions, modifying table attributes, and performing various data retrieval operations. The document serves as a comprehensive guide for executing database queries related to product management.

Uploaded by

sammamehra07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Ip-class12 -Practical File -Database Query Using Mysql.docx

The document provides instructions for creating and managing a MySQL database named 'company' with a table 'products' containing various product details. It includes SQL queries for creating the table, inserting records, displaying data based on specific conditions, modifying table attributes, and performing various data retrieval operations. The document serves as a comprehensive guide for executing database queries related to product management.

Uploaded by

sammamehra07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Database query using MySQL

Create the following table products and write queries given below:

Table: Products
Pcode Pname Qty Price Company

P1001 iPad 120 15000 Apple

P1002 LED TV 100 85000 Sony

P1003 DSLR Camera 10 25000 Philips

P1004 iPhone 50 95000 Apple

P1005 LED TV 20 45000 MI

P1006 Bluetooth Speaker 100 20000 Ahuja

1. Create a database company.


2. To Start Working With The Database Company.
3. Create the above table products.
4. Display the structure of the above table.
5. Insert the records as shown in the table.
6. Display all the records of the above table.
7. Display the records of the table with qty less than 50.
8. Display the records of the table with price between 15000 to 45000.
9. Display the product code and product name of the products whose quantity is between 100
and 120 (both inclusive).
10. Display the records of the table in ascending order of product name.
11. Display the records of the table in descending order of company name.
12. Display the records in ascending order of price.
13. List all the records with the company name apple.
14. Display all the records whose company name starts with the letter ‘p'.
15. Display all the records having the letter ‘e’ in the product name.
16. Display all the records whose company name ends with the letter ‘a'.
17. Add The Constraint Primary Key To The Product Code.
18. Add the constraint not null to the product name.
19. Add the column location to the above table.
20. Modify the attribute of company from 20 to 30.
21. Modify the attribute of company from null to not null.
22. Set the default value of location to Delhi.
23. Remove the constraint primary key from the above table.
24. Display the names of all the products along with their qty sold for 12 months(assuming
qty represents quantity sold per month).
25. Display the company names without repetition.
26. Display the records whose company is apple and price is 15000.
27. Display all the records except the records with company name sony.
28. Remove the attribute location from the above table.
29. Display the product number, product name, price and company in the ascending order of their
price.
30. Display the contents of the table in the descending order of their price.
31. Display product name (last four letters only), qty, price and company for price in between 30000
to 80000.
32. Join the columns product name and company and display in tabular form like - <pname>
‘manufatured by’ company.
33. Display all the records whose product code is either p1001,p1002,or p1003.
34. Display unique products from the table.
35. Display maximum price of products.
36. Display the total quantities of all products.
37. Display the average price of led tv and apple products.
38. Find the difference between maximum price and minimum price from the table.
39. Display unique products from the table.
40. Count the unique company from products
41. Display product minimum price for each company.
42. Display the maximum price of products manufactured by apple.
43. Round the value of pi (3.14159) to two decimal places.
44. Calculate the remainder when 125 is divided by 8.
45. Display the number of characters in the word 'philips’.
46. Display details from pname column after removing any leading and trailing spaces.
47. Determine the count of rows in the products table.
48. Display the number of characters in each company.
49. Display book titles in lowercase.
50. Display all the records of the table products with company name 4 characters.

You might also like