好像什么都来得及,又好像什么都无能为力,蹲下来摸摸自己的影子,说声对不起,跟着我受委屈了。。。
---- 网易云热评
1、添加数据
insert into 专辑 (序号,专辑名称,主打歌,发行时间) values(1,'周杰伦的床边故事','告白气球','2016-6-24');
insert into 专辑 (专辑名称,主打歌,发行时间) values('哎呦,不错哦','鞋子特大号',' 2014-12-26');
insert into 专辑 (序号,专辑名称,主打歌,发行时间) values(4,'十二新作',"明明就",' 2012-12-18');
insert into 专辑 values(3,'惊叹号',"惊叹号",' 2011-11-11'); 必须加id
insert into 专辑 set 序号=5,专辑名称='跨时代',主打歌='跨时代',发行时间='2010-5-18';
insert into 专辑 (专辑名称,主打歌,发行时间) values('魔杰座','说好的幸福呢',' 2008-10-09'),('我很忙','牛仔很忙',' 2007-11-01');
2、删除数据
delete from 专辑 where 序号=3;
delete form 专辑; 删除表的所有内容
3、修改数据
update 专辑 set 专辑名称='12新作' where 序号=4;
4、查询数据
select * from 专辑;
select * from 专辑 where 序号=1;
select 专辑名称,主打歌 from 专辑;
select * from 专辑 where 序号 in(4,7);
select * from 专辑 where 序号 not in(4,7);
select * from 专辑 where 序号 between 1 and 4;
select * from 专辑 where 序号 is [not] null ;
select distinct 序号 from 专辑; 查询字段内容相同的数据
select * from 专辑 where 专辑名称 like '%忙%';
select * from 专辑 where 专辑名称='Jay' or 序号=2 and 发行时间='2000-1-1'; and优先级高于or
select count(*) from 专辑 where 序号>5;
select sum(序号) from 专辑;
select avg(序号) from 专辑;
select max(序号) from 专辑;
select min(序号) from 专辑;
select * from 专辑 order by 专辑名称 asc; desc降序
select * from 专辑 group by 序号;
select count(*),专辑名称 from 专辑 group by 序号>5;
select sum(序号),专辑名称 from 专辑 group by 序号>5 having sum(序号)>12;
select *from 专辑 limit 4;
select *from 专辑 limit 4,2;
select *from 专辑 as zj where zj.序号>4;//给表重命名
select 序号 as id,专辑名称 from 专辑;//给字段重命名
禁止非法,后果自负
欢迎关注公众号:web安全工具库