五、select的5种子句
|
运算符
|
说明
|
|
>
|
|
|
<
|
|
|
=
|
|
|
>=
|
|
|
<=
|
|
|
!=或<>
|
|
|
In
|
在某集合内
|
|
between
|
在某范围内
|
select goods_id,cat_id,goods_name from goods where cat_id in (4,10);
select * from goods where shop_price between 2000 and 3000;
|
运算符
|
说明
|
|
not 或 !
|
逻辑非
|
|
or 或||
|
逻辑或
|
|
and 或&&
|
逻辑与
|
select * from goods where shop_price >=3000 and shop_price <=5000 or shop_price >=500 and shop_price <=1000;
select * from goods where cat_id not in (4,5);
select cat_id,max(shop_price) from goods group by cat_id;
select sum(goods_shuliang) from goods;
select avg(shop_price) from goods;
select count(*) from goods;
select cat_id,sum(shop_price * goods shuliang) from goods group by cat_id;
select cat_id as lanmu from goods;
select goods_id,goods_name,market_price – shop_price as sheng from goods having sheng > 200;
select goods_id,goods_name,market_price – shop_price as sheng from goods where market_price – shop_price >200;
select goods_id,goods_name,market_price – shop_price as sheng from goods where sheng > 200;
Select goods_id,cat_id,market_price – shop_price as sheng from goods where cat_id =3 having sheng >200;
select cat_id,sum(goods_shuliang * shop_price) as k from goods group by cat_id having k>20000;
select 姓名,sum(分数<60) as gk,avg(分数) as pj from stu group by name having gk >= 2 ;
select 姓名,avg(分数) from stu group by name;
select 姓名,分数<60 from stu;
select 姓名,sum(分数<60) from stu group by name;
select 姓名,sum(分数<60) as gk,avg(分数) as pj from stu group by name having gk >= 2 ;
select * from goods order by shop_price desc;
select * from (select goods_id,cat_id,goods_name,shop_price from goods order by cat_id asc,shop_price desc) as tmp group by cat_id;
五、select的5种子句的更多相关文章
- mysql中select五种子句和统计函数
select 五种子句顺序 where 条件 group by 分组 having 把结果进行再次筛选 order by 排序 limit 取出条目 统计函数 max(列名) 求最大 min( ...
- mysql---select的五种子句学习(where、group by、having、order by、limit)
mysql---select的五种子句学习(where.group by.having.order by.limit) 分类: Mysql学习2012-09-27 16:14 1533人阅读 评论 ...
- select 5种子句介绍
一.Where 条件查询 ①where expression 用法:expression为真,则该行取出 运用场合 各种条件查询场合,如按学号查学生,按价格查商品,按发布时间查新闻等 ②select ...
- 小贝_mysql select5种子句介绍
mysql select5种子句介绍 简要 一.五种字句 二.具体解释五种字句 一.五种字句 where.group by.having.order by.limit 二.具体解释五种字句 2.1.理 ...
- oracle数据库【表复制】insert into select from跟create table as select * from 两种表复制语句区别
create table as select * from和insert into select from两种表复制语句区别 create table targer_table as select ...
- 【SQL必知必会笔记(3)】SELECT语句的WHERE子句数据过滤操作
上个笔记主要介绍了利用SELECT语句检索单个/多个/所有列,并利用DISTINCT关键字检索具有唯一性的值.利用LIMIT/OFFSET子句限制结果:以及利用ORDER BY子句排序检索出的数据,主 ...
- select into from和insert into select from两种表复制语句区别
select into from和insert into select from两种表复制语句都是将源表source_table的记录插入到目标表target_table,但两句又有区别. 第一句(s ...
- SQL SELECT TOP, LIMIT, ROWNUM 子句
SQL SELECT TOP, LIMIT, ROWNUM 子句 SQL SELECT TOP 子句 SELECT TOP 子句用于规定要返回的记录的数目. SELECT TOP 子句对于拥有数千条记 ...
- mysql之select+五种子句的理解
select 可以包含很复杂,很丰富的逻辑,最能考验一个人的逻辑思维能力和sql语句的掌握程度,我是这么认为,以前的很多次面试几乎都死在它手上,所以才有了今天的这篇日志,下定决心把它学好. where ...
随机推荐
- 01-CSS3-justify-content: space-around; justify-content: space-between;
/* justify-content: space-around; 运用在父级元素上 第一个子元素距离左边的距离==最后一个子元素距离右边的距离 除第一个子元素和最后一个子元素外,第2个,第3个... ...
- 面向对象程序设计(JAVA) 第11周学习指导及要求
2019面向对象程序设计(Java)第11周学习指导及要求 (2019.11.8-2018.11.11) 学习目标 理解泛型概念: 掌握泛型类的定义与使用: 掌握泛型方法的声明与使用: 掌握泛型接 ...
- Kafka为什么不支持读写分离得原因?-干货
在 Kafka 中,出产者写入音讯.顾客读取音讯的操作都是与 leader 副本进行交互的,从 而结束的是一种主写主读的出产消费模型.数据库.Redis 等都具有主写主读的功用,与此同时还支撑主写从读 ...
- [LOJ 2083][UOJ 219][BZOJ 4650][NOI 2016]优秀的拆分
[LOJ 2083][UOJ 219][BZOJ 4650][NOI 2016]优秀的拆分 题意 给定一个字符串 \(S\), 求有多少种将 \(S\) 的子串拆分为形如 AABB 的拆分方案 \(| ...
- HikariCP连接池
1.HikariCP连接池是什么? HikariCP是数据库连接池,而且是号称史上最快的,而且目前来看确实是这样的,SpringBoot2.0也已经采用HikariCP作为默认连接池配置. githu ...
- 阿里Sentinel支持Spring Cloud Gateway啦
1. 前言 4月25号,Sentinel 1.6.0 正式发布,带来 Spring Cloud Gateway 支持.控制台登录功能.改进的热点限流和注解 fallback 等多项新特性,该出手时就出 ...
- js -- 数组的操作(自己的常用备查)
1.数组的定义 var arr = [],或者 var arr = [1,2,3,4,5] 2.数组的使用 >数组的合并 concat ,,]; ,]; a = a.concat(b); con ...
- (十八)golang--defer关键字
在函数中,程序员经常需要创建资源(比如,数据库连接,文件句柄,锁等),为了在函数执行完毕后,及时释放资源,go设计者提供defer(延时机制) 用defer申明的语句不会立即执行,而是被存入到defe ...
- PHP高级进阶梳理
基础篇 1.深入理解计算机系统 2.现代操作系统 3.C程序设计语言 4.C语言数据结构和算法 5.Unix环境高级编程 6.TCP/IP网络通信详解 7.Java面向对象编程 8.Java编程思想 ...
- .Net轻松处理亿级数据--clickhouse及可视化界面安装介绍
该篇内容由个人博客点击跳转同步更新!转载请注明出处! 前言 我是在17年就听说过Clickhouse,那时还未接触过亿数据的运算,那时我在的小公司对于千万数据的解决方案还停留在分库分表,最好的也是使用 ...