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

MySQL-2

Uploaded by

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

MySQL-2

Uploaded by

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

MySQL

L-13 & 14
Create database MyDatabase2;
Use MyDatabase2;
desc Class12;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| RollNo | int | NO | PRI | NULL | |
| Name | varchar(20) | YES | | NULL | |
| Marks | float(4,2) | YES | | NULL | |
| City | varchar(20) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+

INSERT
Insert into Class13 values(101,"Ram",90.34,"Jaipur");
Insert into Class13 values
(102,"Rohit",90.34,"Patna"),
(103,"Uman",78.34,"Kolkata"),
(104,"Dev",90,"Jaipur"),
(105,"Sonal",99.34,"Goa"),
(106,"Veer",91.46,"Goa"),
(107,"Bhavi",85.34,"Delhi"),
(108,"Mohan",80.45,"Patna");

Insert into Class13(RollNo,Name,City)


values(109,"Joy","Delhi");
Insert into Class13 values(110,Null,Null,"Kolkata");

Alter table Class12 Add column EntryTime Time;


Alter table Class12 Add column AddDate Date;
Insert into Class12
values(111,Null,90.34,"Kolkata","10:30","2024-5-28");
UPDATE
Update Class12 set EntryTime ="10:30";
Update Class12 set Marks = 90 where RollNo = 109;

DELETE
Delete from Class12 where Marks is Null;
Delete from Class12 where City = "Delhi";
Deletefrom Class12;

L-15
Between
Select*from Class13 where Marks between 80 and 90;
Select*from Class13 where Marks not between 80 and
90;

L-16
Select*from class13 where City like "%a";
Select*from class13 where Name like "%a_";
Select*from class13 where Marks like "8_.__";
Select*from class13 where Name like "___";

L-17

Select*from class13 where Marks is Null;


Update Class13 set Marks = 65 where RollNo = 109;
Update Class13 set City ="Mumbai" where RollNo=108;

L-18
Insert into class13 values
(111, "Hella",87.60,"Faridabad");
(112, "Thor",72.25,"Kota"),
(113, "Loki",54.60,"Pune"),
(114, "Groot",68.85,"Delhi"),
(115, "Hulk",76.45,"Mumbai");
Update Class13 set Name="Niall" where RollNo=110;

Select max(Marks) from Class13;


Select min(Marks) from Class13;
Select sum(Marks) from Class13;
Select avg(Marks) from Class13;
Select count(*) from Class13;
Select count(Marks) from Class13;

L-19
Select City, count(*)from Class13 Group by City;
Select City, Sum(marks) from Class13 Group by City;

You might also like