当前位置:网站首页>where、having、group by、order by,is null,not in,子查询,delete,日期函数
where、having、group by、order by,is null,not in,子查询,delete,日期函数
2022-07-29 01:58:00 【Meme_xp】
where
过滤条件,用and,or,not等操作符分隔
如果同时需要and和or怎么办呢?圆括号分组
from 表名
where(…)
or(…)
having和group by
group by分组,having过滤条件
group by …
having …
order by
默认升序
order 列名 desc为降序
order by a,b,c;
a,b,c的顺序决定了排序的次序
用位置而不是用名称排序
order by 3 descs(用第三列降序)
判断null
我使用了左连接查询,学到了只能采用IS NULL或IS NOT NULL,而不能采用=, <, <>, !=这些操作符来判断NULL。
not in
使用 not in 查出不在这些结果中的数据。
select name from customers where id not in (
select customerId from orders
);
子查询

1.select子查询
2.where子查询,如果是集合不能用=,而应该用in


3.from子查询,用于三张表以上的
a,b,c三张表,先查ab,再查询c
delete
单表删除

多表删除:
delete p1 from Person p1 ,Person p2
where p1.Email =p2.Email and p1.Id > p2.Id 多表删除,把p1大于p2的ID删除了
datediff
DATEDIFF是两个日期的天数差集
DATEDIFF(expr1,expr2)
DATEDIFF() 返回 expr1 − expr2,表示为从一个日期到另一个日期的以天为单位的值。expr1 和 expr2 是日期或日期和时间表达式。计算中仅使用值的日期部分。
mysql> SELECT DATEDIFF(‘2007-12-31 23:59:59’,‘2007-12-30’); -> 1
mysql> SELECT DATEDIFF(‘2010-11-30 23:59:59’,‘2010-12-31’); -> -31
边栏推荐
- How does the Devops team defend against API attacks?
- Waiting queue wait_ queue
- 如何在多御安全浏览器中自定义新标签页?
- Read the recent trends of okaleido tiger and tap the value and potential behind it
- Excel uses countif statistics
- Responsive dream weaving template home decoration building materials website
- The first of the five tips for using browsers efficiently is the most practical
- Explain the four asynchronous solutions of JS in detail: callback function, promise, generator, async/await
- 3D模型格式全解|含RVT、3DS、DWG、FBX、IFC、OSGB、OBJ等70余种
- ResNet50+k折交叉验证+数据增强+画图(准确率、召回率、F值)
猜你喜欢

Ten methods to prevent blackmail software from attacking data

【质量】代码质量评价标准

代码实现 —— 多项式的最大公因式(线性代数)

Jetpack -- navigation realizes page Jump

Read the recent trends of okaleido tiger and tap the value and potential behind it
[email protected] The localization rate reaches 100%"/>Quanzhi t3/a40i industrial core board, 4-core [email protected] The localization rate reaches 100%

“12306”的架构到底有多牛逼?

网络安全漏洞管理的探索与实践

What if there is not enough time for adequate testing?

如果非要在多线程中使用 ArrayList 会发生什么?
随机推荐
Navigation -- realize data transmission and data sharing between fragments
【MQTT从入门到提高系列 | 09】WireShark抓包分析MQTT报文
Prometheus + AlertManager 消息预警
[RT learning note 1] RT thread peripheral routine - control LED light flashing
How to quickly design a set of cross end components that support rendering rich text content
如何快速设计一套支持渲染富文本内容的跨端组件
【上传图片2-可裁剪】
Day 15 (VLAN related knowledge)
Excel 打开包含汉字的 csv 文件出现乱码该怎么办?
裂开了,一次连接池参数导致的雪崩问题
3D模型格式全解|含RVT、3DS、DWG、FBX、IFC、OSGB、OBJ等70余种
当Synchronized遇到这玩意儿,有个大坑,要注意
【质量】代码质量评价标准
Jmeter之BeanShell生成MD5加密数据写入数据库
【上传图片可剪裁-1】
实验二:Arduino的三色灯实验
Quanzhi t3/a40i industrial core board, 4-core [email protected] The localization rate reaches 100%
Rust 列表(Vec)复制
What should I do if excel opens a CSV file containing Chinese characters and there is garbled code?
Ten methods to prevent blackmail software from attacking data