增
insert into user(username,password) values('','');
insert into user(username,password) values('',''),('','');
删
delete from user where id = 1;
改
update user set username='222',password='123456' where id = 1;
查
select [all|distinct] * from user [where id=1]
[group by sex having id>3]
[order by id [|desc]]
[limit n,m];
in(1,2,3)
between(100,200)
模糊查询 字段名 like '%a%';
select id,name,age,sex,concat(id,'号叫',name,'---',age,'岁') as aa from user; //查询添加新字段
select id,name,age,if(sex=0,'man','woman') as sex from user; //查询结果sql里if判断
select * from (select id,name,age,if(sex=0,'man','woman') as sex from user) aa where aa.id=1; //查询再查询
select id,name,age,(case when sex=0 then 'man' when sex=1 then 'nv' else 'qita' end ) as sex from user; //case在sql里的语法
select group_concat(id) from user; // 字符串 “1,2,3,4,5,6”
网友评论