SQL statement 2
Menu column data
Select name from totoro;
Select two columns of data
Select id, name from totoro;
Non-repeated data in the menu Column
Select distinct name from totoro;
Select the data whose name is pangpang3 in the name column.
Select * from totoro where name = 'pangpang3 ';
Select data age> 3
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 sorting
Select age from totoro order by age;
Select two columns and sort by age
Select id, age from totoro order by age;
DESC, descending order
Select age, name from totoro order by name DESC;
ASC, ascending
Select name, id from totoro order by name ASC;
Partially inserted
Insert into totoro (id, name) values (10, '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 of limit
Select * from totoro limit 3;
Name ending with I
Select * from totoro where name like '% I ';
Name with om
Select * from totoro where name like '% om % ';
The first character after name is hu's
Select * from totoro where name like '_ hu ';
Name 2nd is a, 4th is k
Select * from totoro where name like '_ a_k ';
The name is tom, ii
Select * from totoro where name in ('Tom ', 'II ');
Name between anan and mary
Select * from totoro where name between 'ananc' and 'Mary ';
As specified alias
Select name as n from totoro;
Table Name totoro as t
Select t. id from totoro as t;
Names with the same IDs in the two tables
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 the data with the same id as the two tables.
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;