五、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 ...
随机推荐
- 5.Java基础_Java算术/字符/字符串/赋值运算符
/* 算术/字符/字符串/赋值 运算符 */ public class OperatorDemo01 { public static void main(String[] args){ //算术运算符 ...
- vue调用高德地图:vue-amap
前言:之前没有接触过页面调用地图的项目,某次面试,老板要求我用vue-amap调用高德地图,回家以后,我去网上查了一些案例和教程,看似很简单的引入调用,我却整整弄了一宿,还没弄出来!!!百般无奈之下, ...
- c# 第23节 外部方法
本节内容: 1:外部方法是什么 2:外部方法的实现 1:外部方法是什么 2:外部方法的实现 样式: 实现方式:很少 用自己多加练习把
- NOIP2018普及组复赛游记
2018年11月10日,NOIP2018普及组复赛. 这是我初中阶段最后一次复赛了. 和往常一样,我们在预定的早上7点,没有出发. 10分钟之后,人终于到齐了,于是出发了,一路无话. 到了南航,合照三 ...
- orchard 中文文档 中英对照版
ORCHARD CMS a free, open source, community-focused Content Management System built on the ASP.NET MV ...
- RSA加密与解密
/// <summary> /// RSA 公钥加密 /// </summary> /// <param name="content">要加密的 ...
- vs2017 升级后无法启动 z
Visual Studio 2017 无法启动,进程中却有devenv.exe运行的解决办法 双击Visual Studio 2017,系统没有响应,在任务管理器中却发现devenv.exe 已经在运 ...
- Beyond Compare的自定义破解方法
因本人是程序员的缘故,经常时不时就是几千几万行代码找不同,也就时常要用到一个超级无敌好用的文本对比软件:Beyond Compare. 然而破解成了一大问题,网上有很多注册码都已经被封了或者是注销掉了 ...
- cmake打印shell
cmake链接库失败时,可通过打印路径下对应的lib来定位问题 execute_process(COMMAND ls -lt ${CMAKE_CURRENT_SOURCE_DIR}/lib #执行sh ...
- Layui新手教程----帮助小白少走弯路
Layui的学习 Layui官方文档:https://www.layui.com/ 先说说为啥我接触到了layui,因为需要去参与做一个项目,被学长推荐去学习layui,用来处理一些前端的问题. La ...