You are on page 1of 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