这篇文章主要讲解了MySQL中完整的select语句的用法,内容清晰明了,对此有兴趣的小伙伴可以学习一下,相信大家阅读完之后会有帮助。
创新互联服务项目包括正宁网站建设、正宁网站制作、正宁网页制作以及正宁网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,正宁网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到正宁省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
完整语法:
先给一下完整的语法,后面将逐一来讲解。
基础语法:select 字段列表 from 数据源;
完整语法:select 去重选项 字段列表 [as 字段别名] from 数据源 [where子句] [group by 子句] [having子句] [order by 子句] [limit子句];
示例:
去重前: ,去重后
create table student(name varchar(15),gender varchar(15)); insert into student(name,gender) values("lilei","male"); insert into student(name,gender) values("lilei","male"); select * from student; select distinct * from student;
示例:
使用前:,使用后
create table student(name varchar(15),gender varchar(15)); insert into student(name,gender) values("lilei","male"); insert into student(name,gender) values("lilei","male"); select * from student; select name as "姓名",gender as "性别" from student;
-- 示例 select name from (select * from student) as d;
where几种语法:
select name as n ,gender from student where name ="lilei"; -- select name as n ,gender from student where n ="lilei"; --报错 select name as n ,gender from student having n ="lilei";
-- 示例 select name,gender,count(name) as "组员" from student as d group by name; select name,gender,count(name) as "组员" from student as d group by name,gender;
-- 示例 select name as n ,gender from student having n ="lilei"; select name,gender,count(*) as "组员" from student as d group by name,gender having count(*) >2 ;-- 这里只显示记录数>2的分组
-- 示例 select * from student order by name; select * from student order by name,gender; select * from student order by name asc,gender desc;
-- 示例 select * from student limit 1; select * from student limit 3,1; select * from student where name ="lilei" limit 1; select * from student where name ="lilei" limit 3,1;
看完上述内容,是不是对mysql中完整的select语句的用法有进一步的了解,如果还想学习更多内容,欢迎关注创新互联行业资讯频道。
新闻名称:mysql中完整的select语句的用法
浏览地址:https://www.cdcxhl.com/article2/joddic.html
成都网站建设公司_创新互联,为您提供自适应网站、Google、品牌网站制作、外贸建站、云服务器、建站公司
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联