0% found this document useful (0 votes)
10 views4 pages

Cie B

The document describes SQL commands to create a Product_master table with product information like name, description, distributor details, price and quantity. It then inserts sample data for 10 products and runs various SELECT queries to retrieve product details based on different conditions on attributes like price, quantity and distributor. The table is later renamed to Product_information and a new column Contact_of_Distri is added.

Uploaded by

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

Cie B

The document describes SQL commands to create a Product_master table with product information like name, description, distributor details, price and quantity. It then inserts sample data for 10 products and runs various SELECT queries to retrieve product details based on different conditions on attributes like price, quantity and distributor. The table is later renamed to Product_information and a new column Contact_of_Distri is added.

Uploaded by

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

create table Product_master

(
P_number int,
P_name varchar(15),
Description varchar(40),
Distributor_name varchar(15),
Distributor_city varchar(10),
Price int,
Quantity int
);

insert into Product_master values(1,'Pen','Red colour','ABC','Surat',700,20);


insert into Product_master values(2,'Brush','Soft tickels','ABC','Bardoli',50,7);
insert into Product_master values(3,'Nail cuter','Sharp blade','Manoj
tiwari','Bharuch',700,20);
insert into Product_master values(4,'Note Book','A-4 size','Rao
saheb','Bardoli',120,3);
insert into Product_master values(5,'Chowk','Dust less','Jignesh
javiya','Dang',120,0);
insert into Product_master values(6,'Duster','Red colour','ABC','Surat',180,0);
insert into Product_master values(7,'Lock and key','Unbreckable
steel','ABC','Surat',700,0);
insert into Product_master values(8,'Tooth paste','Red
colour','ABC','Surat',130,3);
insert into Product_master values(9,'Soup','Nice smell','Dax','Surat',110,9);
insert into Product_master values(10,'Tpuch pad','Smooth touch','Dilip
bhai','Bardoli',1000,6);

select * from Product_master;


+----------+--------------+-------------------+-----------------+------------------
+-------+----------+
| P_number | P_name | Description | Dstributor_name | Distributor_city
| Price | Quantity |
+----------+--------------+-------------------+-----------------+------------------
+-------+----------+
| 1 | Pen | Red colour | ABC | Surat
| 700 | 20 |
| 2 | Brush | Soft tickels | ABC | Bardoli
| 50 | 7 |
| 3 | Nail cuter | Sharp blade | Manoj tiwari | Bharuch
| 700 | 20 |
| 4 | Note Book | A-4 size | Rao saheb | Bardoli
| 120 | 3 |
| 5 | Chowk | Dust less | Jignesh javiya | Dang
| 120 | 0 |
| 6 | Duster | Red colour | ABC | Surat
| 180 | 0 |
| 7 | Lock and key | Unbreckable steel | ABC | Surat
| 700 | 0 |
| 8 | Tooth paste | Red colour | ABC | Surat
| 130 | 3 |
| 9 | Soup | Nice smell | Dax | Surat
| 110 | 9 |
| 10 | Tpuch pad | Smooth touch | Dilip bhai | Bardoli
| 1000 | 6 |
+----------+--------------+-------------------+-----------------+------------------
+-------+----------+

select P_name,Price,Description from Product_master;


+--------------+-------+-------------------+
| P_name | Price | Description |
+--------------+-------+-------------------+
| Pen | 700 | Red colour |
| Brush | 50 | Soft tickels |
| Nail cuter | 700 | Sharp blade |
| Note Book | 120 | A-4 size |
| Chowk | 120 | Dust less |
| Duster | 180 | Red colour |
| Lock and key | 700 | Unbreckable steel |
| Tooth paste | 130 | Red colour |
| Soup | 110 | Nice smell |
| Tpuch pad | 1000 | Smooth touch |
+--------------+-------+-------------------+

select P_name,Quantity from Product_master where Distributor_name='ABC';


+--------------+----------+
| P_name | Quantity |
+--------------+----------+
| Pen | 20 |
| Brush | 7 |
| Duster | 0 |
| Lock and key | 0 |
| Tooth paste | 3 |
+--------------+----------+

select P_name from Product_master where Price>150;


+--------------+
| P_name |
+--------------+
| Pen |
| Nail cuter |
| Duster |
| Lock and key |
| Tpuch pad |
+--------------+

select P_name from Product_master where quantity=0;


+--------------+
| P_name |
+--------------+
| Chowk |
| Duster |
| Lock and key |
+--------------+
select * from Product_master where Price=700 and Quantity=20;
+----------+------------+-------------+------------------+------------------
+-------+----------+
| P_number | P_name | Description | Distributor_name | Distributor_city | Price
| Quantity |
+----------+------------+-------------+------------------+------------------
+-------+----------+
| 1 | Pen | Red colour | ABC | Surat | 700
| 20 |
| 3 | Nail cuter | Sharp blade | Manoj tiwari | Bharuch | 700
| 20 |
+----------+------------+-------------+------------------+------------------
+-------+----------+

> Alter table Product_master


-> Rename column Quantity to Quantity_in_hand;
+------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+-------------+------+-----+---------+-------+
| P_number | int | YES | | NULL | |
| P_name | varchar(15) | YES | | NULL | |
| Description | varchar(40) | YES | | NULL | |
| Distributor_name | varchar(15) | YES | | NULL | |
| Distributor_city | varchar(10) | YES | | NULL | |
| Price | int | YES | | NULL | |
| Quantity_in_hand | int | YES | | NULL | |
+------------------+-------------+------+-----+---------+-------+

select P_name from Product_master where Price>100 and Quantity_in_hand<5;


+--------------+
| P_name |
+--------------+
| Note Book |
| Chowk |
| Duster |
| Lock and key |
| Tooth paste |
+--------------+

Alter table Product_master


-> Add Contact_of_Distri int;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| P_number | int | YES | | NULL | |
| P_name | varchar(15) | YES | | NULL | |
| Description | varchar(40) | YES | | NULL | |
| Distributor_name | varchar(15) | YES | | NULL | |
| Distributor_city | varchar(10) | YES | | NULL | |
| Price | int | YES | | NULL | |
| Quantity_in_hand | int | YES | | NULL | |
| Contact_of_Distri | int | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+

select Distributor_name,Distributor_city,Contact_of_Distri from Product_master


where Distributor_city='Surat' or Distributor_city='Bardoli';
+------------------+------------------+-------------------+
| Distributor_name | Distributor_city | Contact_of_Distri |
+------------------+------------------+-------------------+
| ABC | Surat | NULL |
| ABC | Bardoli | NULL |
| Rao saheb | Bardoli | NULL |
| ABC | Surat | NULL |
| ABC | Surat | NULL |
| ABC | Surat | NULL |
| Dax | Surat | NULL |
| Dilip bhai | Bardoli | NULL |
+------------------+------------------+-------------------+

select P_name,Price from Product_master where Price>100 and Quantity_in_hand


between 5 and 10;
+-----------+-------+
| P_name | Price |
+-----------+-------+
| Soup | 110 |
| Tpuch pad | 1000 |
+-----------+-------+

Alter table Product_master


-> Rename Product_information;
mysql> desc Product_information;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| P_number | int | YES | | NULL | |
| P_name | varchar(15) | YES | | NULL | |
| Description | varchar(40) | YES | | NULL | |
| Distributor_name | varchar(15) | YES | | NULL | |
| Distributor_city | varchar(10) | YES | | NULL | |
| Price | int | YES | | NULL | |
| Quantity_in_hand | int | YES | | NULL | |
| Contact_of_Distri | int | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy