Select single column data
Select name from Totoro;
Select two columns of data
Select Id,name from Totoro;
Select data that is not duplicated in a single column
Select distinct name from Totoro;
Select the name in the Name column as the pangpang3 data
SELECT * from Totoro where name= ' pangpang3 ';
Select the age>3 data
SELECT * FROM Totoro where age>3;
and
SELECT * from Totoro where id=1 and age=1;
or
SELECT * from Totoro where id=1 or age=3;
ORDER by sort
Select age from Totoro order by age;
Select two columns, sort by age
Select Id,age from Totoro order by age;
DESC, descending
Select Age,name from Totoro order by name DESC;
ASC, ascending
Select Name,id from Totoro order by name ASC;
Partial Insertion
Insert into Totoro (id,name) VALUES (, ' Feifei ');
Partial Update
Update Totoro set id=13,name= ' Mark ' where age=9;
Delete
Delete from Totoro where id=1;
Select the first 3 lines limit
SELECT * from Totoro limit 3;
the name ending with I
SELECT * from Totoro where name is like '%i ';
name with Om
SELECT * from Totoro where name is like '%om% ';
name the first word specifier is Hu's
SELECT * from Totoro where name is like ' _hu ';
name 2nd is a, and the 4th is K.
SELECT * from Totoro where name is like ' _a_k ';
name is tom,ii
SELECT * from Totoro where name in (' Tom ', ' II ');
take the name between Anan and Mary
SELECT * from Totoro where name between ' Anan ' and ' Mary ';
As specifies an alias
Select Name as n from Totoro;
table name Totoro as T
Select T.id from Totoro as T;
two name in table with ID equal
Select Totoro.id,totoro.name,user.name from Totoro,user where totoro.id=user.id;
join on
Select Totoro.id,totoro.name,user.name from Totoro join user on Totoro.id=user.id order by Totoro.id;
Take two data with the same ID in the table
Select Totoro.id,totoro.name,user.name from Totoro,user where totoro.id=user.id;
INNER JOIN
Select Totoro.id,totoro.name,user.id from Totoro inner JOIN user on Totoro.id=user.id order by Totoro.id;
SQL statement Two