select * from t_hq_ryxx;

select bianh,xingm from t_hq_ryxx;

--为字段名定义别名
select bianh as 编号,xingm as 姓名 from t_hq_ryxx; select bianh 编号 from t_hq_ryxx; select bianh || xingm as 编号和姓名 from t_hq_ryxx; select bianh as bh, t.* from t_hq_ryxx t order by bianh desc; --order by 排序,desc降序排序
select bianh as bh, t.* from t_hq_ryxx t order by xingb desc,bum desc; --nulls last/first的用法,desc或者asc要放在nulls前面
select bianh ,xingm ,bum,xingb from t_hq_ryxx t order by bum desc nulls last,xingb; --选择排序为8的字段
select * from t_hq_ryxx order by 8; --由bum和bianh列来定义排序方式
select * from t_hq_ryxx order by bum || bianh;
--相加的字段若有空则结果为空
select * from t_hq_ryxx order by nianl + gongz; select nianl,gongz, (nianl + gongz) as g from t_hq_ryxx order by (nianl + gongz) desc;
--为字段的和定义别名,并以此为排序定义方式
select nianl,gongz, (nianl + gongz) as g from t_hq_ryxx order by g; select * from t_hq_ryxx;
--选择bum为102或者103,性别为女的行
select * from t_hq_ryxx where (bum = '' or bum = '') and xingb = 2;
--选择bum不为空的行
select * from t_hq_ryxx where bum is not null; --去重复
select distinct bum,xingb from t_hq_ryxx; --模糊查询 % 通配符 _ 通配一位
select * from t_hq_ryxx where xingm like '%阿%'; select * from t_hq_ryxx where bianh in ('','',''); select * from t_hq_ryxx where bianh = '' or bianh = '' or bianh = ''; select * from t_hq_ryxx where gongz between '' and ''; select * from t_hq_ryxx where gongz >= 1000 and gongz <= 2000; --子查询
select * from t_hq_ryxx where bum in (select bumenbm from t_hq_bm where lianxidh = ''); select * from t_hq_ryxx where gongz > all (select pingjgz from t_hq_bm); --分组-
select bum, count(1) as 数量 from t_hq_ryxx group by bum; select bum, count(1) as 数量,avg(gongz) as 平均值,sum(gongz) as 合计 from t_hq_ryxx group by bianh, bum;
--分组基础上过滤
select bum, count(1) as 数量,avg(gongz) as 平均值,sum(gongz) as 合计 from t_hq_ryxx group by bum having avg(gongz) > 2000; select bum, count(1) as 数量,avg(gongz) as 平均值,sum(gongz) as 合计 from t_hq_ryxx where bum is not null group by bum having avg(gongz) > 2000;

DQL查询语句内容整理的更多相关文章

  1. 6.1课堂笔记—DML(数据操作语言),DQL查询语句

    一.DML(数据操作语言) InnoDB MyISAM 支持事务 不支持事务 不支持全文索引 支持全文索引 支持外键约束 不支持 命令查看默认存储引擎 show variables like '%st ...

  2. DQL查询语句使用(select)

      9)DQL查询语句使用   SELECT语句在PL/SQL中使用,必须 采用下面用法:     select id INTO 变量   from t001 where id=5;    将记录字段 ...

  3. SQL中的DQL查询语句

    目录 1. DQL:查询语句 排序查询 聚合函数 分组查询 分页查询 2. 约束 3. 多表之间的关系 4. 范式 DQL:查询语句 1. 排序查询 语法:order by 子句 order by 排 ...

  4. oracle(5)--DQL查询语句

    DQL 数据查询语句(data query language) 1.查询条件符号: < ,  > ,  = ,    <= ,  >= ,    != ,  < > ...

  5. Mysql中的DQL查询语句

    ----------------1.查询所有列 --查询 学生 表所有记录(行) select *from 学生 --带条件的查询 select *from 学生 where 年龄>19 --- ...

  6. 关于MySql经典高频查询语句的整理

    一查询数值型数据: SELECT * FROM tb_name WHERE sum > 100; 查询谓词:>,=,<,<>,!=,!>,!<,=>,= ...

  7. SQL结构化查询语句

    SQL结构化查询语句 SQL定义了查询所有关系型数据库的规则. 1.通用语法 SQL语句可以单行或者多行书写,以分号结尾 可以使用空格和缩进增强可读性 不区分大小写,但是关键字建议大写 3种注释 注释 ...

  8. MySQL数据库的创建和基本的查询语句

    数据库的定义 数据库是按照数据结构来组织.存储和管理数据的建立在计算机存储设备上的仓库 分类 非结构化数据: 数据相对来说没有固定的特点 半结构化数据: 数据之间有着相同的存储结构 属性 值 每一条数 ...

  9. 在Delphi中动态地使用SQL查询语句 Adoquery sql 参数 冒号

    在Delphi中动态地使用SQL查询语句 在一般的数据库管理系统中,通常都需要应用SQL查询语句来提高程序的动态特性.下面介绍如何在Delphi中实现这种功能.在Delphi中,使用SQL查询语句的途 ...

随机推荐

  1. accessor method & mutator method

    import java.time.*; public class MyTest{ public static void main(String[] args){ LocalDate date = Lo ...

  2. poj3334Connected Gheeves(二分)

    链接 二分高度,算面积的地方有点麻烦,没有用求交点的模板,直接自己按三角形相似手算了一下,写的有点麻烦. 上下界直接取水可放的最高点以及最低点. 自己的长得很挫的代码 #include <ios ...

  3. epoll中et+多线程模式中很重要的EPOLL_ONESHOT实验

    因为et模式需要循环读取,但是在读取过程中,如果有新的事件到达,很可能触发了其他线程来处理这个socket,那就乱了. EPOLL_ONESHOT就是用来避免这种情况.注意在一个线程处理完一个sock ...

  4. 树状数组求逆序对:POJ 2299、3067

    前几天开始看树状数组了,然后开始找题来刷. 首先是 POJ 2299 Ultra-QuickSort: http://poj.org/problem?id=2299 这题是指给你一个无序序列,只能交换 ...

  5. QQ聊天即时代码

    QQ即时聊天代码:[需对方已经即时聊天工具功能 开通入口http://shang.qq.com/v3/widget.html] tencent://Message/?Uin=84065994& ...

  6. Google Chrome input 设置 line-height 后光标变得和input一样高

    Google Chrome input的height和line-height设置为相同的比默认高度高的值时,当input控件获得焦点并且没有输入内容时,input中的光标会占满整个input控件(如果 ...

  7. The Daligner Overlap Library

    /************************************************************************************\ * * * Copyrig ...

  8. PS去掉图片上的文字的6种基本方法,动态教程

    1.使用仿制图章工具去除文字这是比较常用的方法.具体的操作是,选取仿制图章工具,按住Alt键,在无文字区域点击相似的色彩或图案采样,然后在文字区域拖动鼠标复制以复盖文字.要注意的是,采样点即为复制的起 ...

  9. IOS下移除按钮原生样式 -webkit-appearance

    IOS环境下的按钮都是经过美化的,但通常我们在设计web app的时候不需要这些看上去老土的样式,所以,去除这些显得很有必要. 下面这句代码就是重置这些样式的: -webkit-appearance: ...

  10. swiper轮播图--兼容IE8

    //引入idangerous.swiper.min.js var mySwiper = new Swiper ('.swiper-container', { loop: true, paginatio ...