Mysql数据库入门---数据查询常用方法(包含条件查询和排序查询)
发布时间:2022-09-19 14:39:23 所属栏目:MySql教程 来源:
导读: Mysql数据库入门—数据查询
Author:qyan.li
Date:2022.2.21
文章目录
1. select关键字
select意为选择之意,可以借助于select关键字完成数据库内容的查询
Author:qyan.li
Date:2022.2.21
文章目录
1. select关键字
select意为选择之意,可以借助于select关键字完成数据库内容的查询
|
Mysql数据库入门—数据查询 Author:qyan.li Date:2022.2.21 文章目录 1. select关键字 select意为选择之意,可以借助于select关键字完成数据库内容的查询 去除重复数据: 数据库应用中,某些时刻会需要提炼出某字段中所有不相重复的数据,此时需要distinct关键字tinct select name from student_information.pet; select distinct name from student_information.pet; 2.条件查询 数据库查询过程中,经常会遇到筛选出满足特定条件的数据MySQL 查询数据,此时会需要where关键字,后加筛选条件完成数据的查询,一般形式为select 字段名 from 数据表名称 where 筛选条件 简单示例: select owner from student_information.pet where name = 'liqiyan'; select gnp/gnpold,name from country where gnp/gnpold > 1.1; select * from student_information.pet where not(name = 'liqiyan' and sex = 'm'); 运算符筛选查询: 运算符筛选种类、组合多样,可根据需要自行组合,此处仅介绍重难点筛选方法 3.排序查询 在数据库查询操作中,经常会遇到数据需要按照一定的规则进行排序,此时会应用到sql语句中的排序查询关键字order by,结合asc和desc可以实现降序、升序的排列,一般语法规则为select from where order by 排序列表 在排序中,存在asc和desc两种排序规则,分别为升序和降序,默认情况下为降序 简单示例: # 按照人口进行降序排列,显示国家名称 select name,population from world.country order by population desc; # 按照GDP增长的比例升序排列 select name,GNP,GNPOld,GNP/GNPOld GNP增长率 from world.country order by GNP增长率 asc. (编辑:我爱制作网_池州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐


浙公网安备 33038102330577号