My sql
3 min readNov 20, 2020
structure query language.
- How to see current database where we are working=select database();
- How many data types in mysql=numeric type,string type,date time.
- IN numeric there is int,float =int we are using for whole number float for decimal number.
- In string there is varchar=we can write alphabet and we must have to decide length and the length is start from(1–255)
- IN date there is date= there is format y-m-d
- DDl (Data defination language)=are used to define or redfine schema object.
- DMl (DATA MANIPULATION LANGUAGE)=are usedd to manipulate data.
- Tcl(TRANSICTION CONTROL LANGUAGE =to manage transiction;
- The where clause is used to select specific rows.
- Between operator=making range
- in operator= selecting values form a list of values.
- like operator=making character comparison using strings.
- Alter table=can add exciting column and be redefined. for deleting (alter table table name drop column column name)for adding(alter table tablename add columnname datatypes.
- drop=for delete
- Primary key= it is a constraint its must contain unique values and cannot contain null.create table tablename(
-> name varchar(250),
-> id int not null,
-> primary key (name) )Foreign key=we are using for link two tables together - show table=for checking or watching table
- insert =insert into tablename values(column 1 datatypes);
- table data show =select * from tablename;
- warnings=show warnings;(if datatype we will write another data type)
- Null=the value is unknown ,its doesnt mean zero.
- not null=it mean we have to give value.if we will not give galue it will automatic come int num.
- default value in table=if we will not five any value then it will come default value. create table stu_form(stude_name varchar(250) not null default “isha”,
-> stu_age int not null default 18);insert into stu_form values(); it will give default value. - auto_increment =Its taking auto,atic number create table table_name(
-> id int not null auto_increment,
-> name varchar (55),age int,
-> primary key(id) ); - where=select * from table name where age 20; if i want age name who is 20.select coloumn name from table .if i want row name
- Distinct statement=IT will remove dupluicate. if two name will there and the both name will same then it will give only one number.(select distinct column name from table_name.
- order by =we are using for ascending and descending order.
- Like operator=select column name from table name where name like “%a”; it will print if any name and in last there is a ,”a%” it will print if there is starting in A.
- comparison operator =Its compare two number
- (=) equal operator we are using (select * from table name where columnname =20; herer if any row_value is 20 then it will print. (select * count rowname from table name where columnname =20) it will give how many people who have 20 age.
- sum=it will add
- min = it will give minimum number
- Not equal operator=(!=)(<>).
- Logical operator = And (&&)(the both conditon will true then it will print True ) select * from tablenamea where roename=”isha” and rowname=31; )if the both will true then it will print other wise it will come empty set.(or) if the one condition will true then also it will print.
- Group by =it will give result by set where we are using avg sum count.
- Foregin key =it used to link two table
- join =we are joining two table
- (INNER) JOIN: Returns records that have matching values in both tables
- LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
- RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
- FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table.
38. how to join two table=
create table customer(cid int not null auto_increment primary key,cname varchar(255) ); think
39. show databases =for checking database;
40. show database table name = for chekin table data.
LEARN MORE KEEP MORE BE CALM AND LEARNING WELLL.
GOD BLESS YOU.