You are on page 1of 2

MYSQL

to work in mysql , we first have to create a database and make it default to use.
> use ABC;
to create a databse ABC
create databae ABC;
> use ABC;

#to create a table


>create table( );
There are mainly 4 types of inputs in mysql that are:-
char
varchar
Date/Time
numeric

I numeric we have 3 types of inputs that are int, decimal , number

> create table(No int, class char(3) , name varchar(20));

to show all the available databases we ave to use the command


>show databass;

#to display the table we have to use the command desc XYZ

#to insert the values in to table the command is as follows;


> insert into XYZ values(1, "XII", "Hisar");

#to specify thecolumn names we have to use the:-

insert into XUZ( mp, ma, values)2, "XI");

>Select * from student

#Null value
>null is a specific value in python and mysql, when the original value is not
availabe the null value is used.
# it can also be ter,ed as a empty data value

# To insert a column in a table

> insert into student


(Class, Name , Marks) values (12,'H', 80) ;

# to know how many class students are available in a table

> select class from student;

# Distinct- to remove duplicate data data from a table

>Select distinct (class) from student;

#Aggregate functions
It is an inbuilt functions available to apply on a column in a table
Max-
Min-
Avg-
Count-
Count(*)

#Note- Count(*) ia used to count the values including the null.


>Select count(marks) from student;
>Select count(*) marks from student;

# also the average value of the table will change in the case of a null statement

Select * from emp


order by Name;
group by is used to make a group of similar type of values.
Select * from emp
group by designation

Select class Cibt(8) class;


from emp
group by 'class';

# where is not used in group by instead we will use having.

select distinct (Designation)


from emp;

Select designation from emp group by designation;

Group by makes group of similar or identical values.

# to count the values in a particular group we use count start


Select designation count(*) from emp group by designation;

You might also like