五、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 ...
随机推荐
- Centos 7 自动安装系统-pxe
一.简介 PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服 ...
- day51_9_15_Django
一.pycharm接受网页信息原理. 如何实现在后端接受浏览器的数据,并解析出有用的信息呢? 使用socket编写网络连接,然后通过浏览器访问ip+端口号. import socket def ind ...
- day45_9_4前端(2)css
一.css的三种css导入: 1.在标签中内部定义(不推荐). 2.在head中的style总定义样式. 3.使用link链接外部的css文件. <!DOCTYPE html> <h ...
- [C0] 人工智能大师访谈 by 吴恩达
人工智能大师访谈 by 吴恩达 吴恩达采访 Geoffery Hinton Geoffery Hinton主要观点:要阅读文献,但不要读太多,绝对不要停止编程. Geoffrey Hinton:谢谢你 ...
- <String> 179 ,6, 168
179. Largest Number 冒泡排序,每一轮都把最小的数字选出放在最后. class Solution { public String largestNumber(int[] nums) ...
- 怎样把ndarray转换为PyQt中的QPixmap
找不到文档,只在网上找到一些语焉不详,执行错误的代码,鼓捣了一个晚上,研(luan)究(gao)成功 def img2pixmap(self, image): Y, X = image.shape[: ...
- Pandownload倒下了,还有它,又一款百度云下载神器,速度可达10M/s
最近很多小伙伴反馈 Pandownload 不好使了 对此我表示 脑壳疼 不过经过一番折腾 还是找到了一个不错的替代品 它就是 baidupcs-web 下载解压后就这么一个可执行文件 干净的不可思议 ...
- Apache Maven 3.6.3配置安装
1.maven 3.5 下载地址:http://maven.apache.org/download.cgi 2.下载了解压到 3.配置环境变量 4.测试看是否安装成功 5.maven配置(全局配置,用 ...
- Mysql中使用JDBC流式查询避免数据量过大导致OOM
一.前言 java 中MySQL JDBC 封装了流式查询操作,通过设置几个参数,就可以避免一次返回数据过大导致 OOM. 二.如何使用 2.1 之前查询 public void selectData ...
- Elasticsearch搜索调优权威指南 (1/3)
本文首发于 vivo互联网技术 微信公众号 https://mp.weixin.qq.com/s/qwkZKLb_ghmlwrqMkqlb7Q英文原文:https://qbox.io/blog/ela ...