五、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 ...
随机推荐
- 7.Java基础_Java数据输入
import java.util.Scanner; public class Output { public static void main(String[] args){ Scanner sc=n ...
- (day52)四、视图层、模板层
目录 一.视图层 (一)Request和Response对象 (1)Request对象 (2)Response对象 (二)JsonResponse对象 (1)前后端分离 (2)json_dumps_p ...
- Semantic 3D
Semantic 3D 这个数据级别的训练集有一个小BUG,是这个neugasse_station1_xyz_intensity_rgb.7z, 解压之后的名字是station1_xyz_intens ...
- LG3205/BZOJ1996 「HNOI2010」合唱队 区间DP
区间DP 区间DP: 显然是一个区间向左右拓展形成的下一个区间,具有包含关系,所以可以使用区间DP. 状态设计: 考虑和关路灯一样设计状态 因为不知道当前这个区间是从哪个区间拓展而来,即不知道这个区间 ...
- Winform重写键盘按键事件
/// <summary> /// 重写键盘处理事件,处理退出和回车按钮 /// </summary> protected override bool ProcessCmdKe ...
- x1
//程序功能: //要求客户从键盘输入一个整数,判断其是奇是偶 #include <stdio.h> int main(){ int x; printf("输入一个整数:\n&q ...
- [LOJ 2133][UOJ 131][BZOJ 4199][NOI 2015]品酒大会
[LOJ 2133][UOJ 131][BZOJ 4199][NOI 2015]品酒大会 题意 给定一个长度为 \(n\) 的字符串 \(s\), 对于所有 \(r\in[1,n]\) 求出 \(s\ ...
- 数据仓库010 - MySQL查看所有存储过程,函数,视图,触发器
.查询数据库中的存储过程和函数 方法一: select `name` from mysql.proc where db = 'your_db_name' and `type` = 'PROCEDURE ...
- 爬虫——控制台抓包和requests.post()发送请求
控制台抓包 打开方式及常用选项 1.打开浏览器,F12打开控制台,找到Network选项卡 2.控制台常用选项 1.Network: 抓取网络数据包 1.ALL: 抓取所有的网络数据包 2.XHR:抓 ...
- idea修改svn地址
1.不能直接修改idea中的svn路径 2.需要先修改小乌龟地址,先找到本地的项目文件右键