PostgreSQL入门到实战
- PostgreSQL数据过滤(七)
-
- 官网地址
- PostgreSQL概述
- [PostgreSQL中BETWEEN 命令理论](#PostgreSQL中BETWEEN 命令理论)
- [PostgreSQL中BETWEEN 命令实战](#PostgreSQL中BETWEEN 命令实战)
- 更新计划
PostgreSQL数据过滤(七)
BETWEEN运算符允许您检查值是否在值的范围内。
官网地址
声明: 由于操作系统, 版本更新等原因, 文章所列内容不一定100%复现, 还要以官方信息为准
bash
https://www.postgresql.org/
PostgreSQL概述
PostgreSQL: 世界上最先进的开源关系数据库。
PostgreSQL中BETWEEN 命令理论
-
如果该值大于或等于低值且小于或等于高值,则BETWEEN运算符返回true;否则,返回false。
-
语法示意
bashvalue BETWEEN low AND high;
-
类似的语法
bashvalue >= low AND value <= high value NOT BETWEEN low AND high value < low OR value > high
PostgreSQL中BETWEEN 命令实战
数据库样例数据来源: https://blog.csdn.net/zwq56693/article/details/137473602
-
使用BETWEEN运算符检索payment_id介于17510和17505之间的付款
bashSELECT payment_id, amount FROM payment WHERE payment_id BETWEEN 17503 AND 17505 ORDER BY payment_id;
-
使用NOT BETWEEN运算符查找payment_id不在17510和17505之间的付款
bashSELECT payment_id, amount FROM payment WHERE payment_id NOT BETWEEN 17503 AND 17505 ORDER BY payment_id;
-
使用BETWEEN运算符查找付款日期在2007-02-14和2007-02-20之间且金额超过10的付款
bashSELECT payment_id, amount, payment_date FROM payment WHERE payment_date BETWEEN '2007-02-15' AND '2007-02-20' AND amount > 10 ORDER BY payment_date;
更新计划
欲知后事如何, 请听下回分解