跳转到内容
搜索文档

运算符

最后更新 查看 MarkdownAgent 设置

支持以下运算符:

算术运算符

Operator 描述
+ 加法
- 减法
* 乘法
/ 除法
% 取模

比较运算符

Operator 描述
= 等于
< 小于
> 大于
<= 小于或等于
>= 大于或等于
<> or != 不等于
IN 当前表达式值在列表中时为 true
column IN ('a', 'list', 'of', 'values')
NOT IN 当前表达式值不在列表中时为 true
column NOT IN ('a', 'list', 'of', 'values')

我们还支持 BETWEEN 运算符检查值是否在 inclusive 范围内:a [NOT] BETWEEN b AND c

模式匹配运算符 New

Operator 描述
LIKE 字符串匹配模式时为 true(区分大小写)
column LIKE 'pattern%'
NOT LIKE 字符串不匹配模式时为 true(区分大小写)
column NOT LIKE 'pattern%'
ILIKE 字符串匹配模式时为 true(不区分大小写)
column ILIKE 'pattern%'
NOT ILIKE 字符串不匹配模式时为 true(不区分大小写)
column NOT ILIKE 'pattern%'

模式匹配支持两种通配符:

  • % 匹配零个或多个任意字符序列
  • _ 匹配任意单个字符

示例:

-- Match strings starting with "error"
WHERE blob1 LIKE 'error%'

-- Match strings ending with ".jpg" (case-insensitive)
WHERE blob2 ILIKE '%.jpg'

-- Match strings containing "test" anywhere
WHERE blob3 LIKE '%test%'

-- Match exactly 5 characters starting with "log"
WHERE blob4 LIKE 'log__'

-- Exclude strings containing "debug" (case-insensitive)
WHERE blob5 NOT ILIKE '%debug%'

布尔运算符

Operator 描述
AND boolean "AND"(两侧均为 true 时为 true)
OR boolean "OR"(任一侧或两侧为 true 时为 true)
NOT boolean "NOT"(后续表达式为 false 时为 true,反之亦然)

一元运算符

Operator 描述
- 取反运算符(例如 -42

这篇文档对您有帮助吗?