PostgreSQL入门到实战
- PostgreSQL数据过滤(一)
- 官网地址
- PostgreSQL概述
- PostgreSQL的where子命令介绍
- PostgreSQL的where子命令实操
- 更新计划
PostgreSQL数据过滤(一)
官网地址
声明: 由于操作系统, 版本更新等原因, 文章所列内容不一定100%复现, 还要以官方信息为准
https://www.postgresql.org/
PostgreSQL概述
PostgreSQL: 世界上最先进的开源关系数据库。
PostgreSQL的where子命令介绍
-
筛选返回的行
SELECT select_list FROM table_name WHERE condition ORDER BY sort_expression;
-
执行顺序
- from -> where -> select -> order by
PostgreSQL的where子命令实操
数据库样例数据来源: https://blog.csdn.net/zwq56693/article/details/137473602
-
相等的操作
SELECT last_name, first_name FROM customer WHERE first_name = 'Jamie';
-
and进行逻辑操作, 满足多个过滤条件
SELECT last_name, first_name FROM customer WHERE first_name = 'Jamie' AND last_name = 'Rice';
-
or逻辑操作, 满足其中的部分条件即可
SELECT first_name, last_name FROM customer WHERE last_name = 'Rodriguez' OR first_name = 'Adam';
-
in满足条件一系列的值
SELECT first_name, last_name FROM customer WHERE first_name IN ('Ann', 'Anne', 'Annie');
-
like加上通配符就是模糊查询, 不然就是等于
SELECT first_name, last_name FROM customer WHERE first_name LIKE 'Ann%';
-
between 大于等于小的值, 小于等于大的值
SELECT first_name, LENGTH(first_name) name_length FROM customer WHERE first_name LIKE 'A%' AND LENGTH(first_name) BETWEEN 3 AND 5 ORDER BY name_length;
-
<>不等于或者!=
SELECT first_name, last_name FROM customer WHERE first_name LIKE 'Bra%' AND last_name <> 'Motley';
更新计划
欲知后事如何, 请听下回分解