五、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 ...
随机推荐
- 初学JavaScript正则表达式(七)
量词 例: \d{20}\w\d?\w+\d*\d{3}\w{3,5}\d{3,} 20次数字字符 单词字符 出现零次或一次数字字符 至少出现一次单词字符 出现任意次数字字符 出现3次数字字符 出现3 ...
- 爬虫 crawlSpider 分布式 增量式 提高效率
crawlSpider 作用:为了方便提取页面整个链接url,不必使用创参寻找url,通过拉链提取器,将start_urls的全部符合规则的URL地址全部取出 使用:创建文件scrapy startp ...
- jmeter从上一个请求使用正则表达式抓取Set-Cookie值,在下一个请求中运用
工作中遇到的问题,登录请求,返回的Response Headers中有个参数Set-Cookie,需要抓取这个参数,运用到下一个请求中,见下图: 通过正则表达式抓取Set-Cookie的值,由于该值存 ...
- SecureCRT自动断开连接的解决方法
方法一: 在普通用户下,输入重启sshd服务的命令:service sshd restart 这时会提示:管理系统服务或单元需要身份验证.解决的方法:先要切换为root用户,接着重启sshd服务:se ...
- 《京东到家订单中心 Elasticsearch 演进历程》----阅读
上篇通过阅读文章对京东到家的架构分析有了初步了解,这次对文章(https://mp.weixin.qq.com/s?__biz=MzU1MzE2NzIzMg==&mid=2247486889& ...
- git使用遇到问题1
1.上传代码过程中遇到 git help gc错误解决方法,有两种方式,推荐第一种方式. $ git fsck $ git gc --prune=now 如果执行完上面的命令还是不行的话,可以尝试删掉 ...
- angular 多路由模块新建组件的方法
More than one module matches. Use skip-import option to skip importing the component into the closes ...
- vue better-scroll
better-scroll在vue项目中的使用 2017年12月21日 18:01:09 阅读数:411 1.准备工作 在项目中安装better-scroll: npm install --save ...
- go 学习笔记之环境搭建
千里之行始于足下,开始 Go 语言学习之旅前,首先要搭建好本地开发环境,然后就可以放心大胆瞎折腾了. Go 的环境安装和其他语言安装没什么特别注意之处,下载安装包下一步下一步直到完成,可能唯一需要注意 ...
- 区块链自问自答 day1
区块链自问自答 day1 简要介绍区块链是什么? 区块链(Blockchain)是一种对等网络下的分布式数据库系统 数据结构中的单向链表是通过每个节点包含一个节点的指针实现"链" ...