Skip to content

Commit

Permalink
docs: update operators and expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
aceforeverd committed Oct 11, 2023
1 parent 953992c commit a1fb0e4
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions docs/zh/openmldb_sql/functions_and_operators/operators.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 运算符
# 表达式和运算符

## 运算符优先级

Expand All @@ -19,9 +19,7 @@
%left UNARY_PRECEDENCE // For all unary operators, +, -, ~
```

## 各类运算

### 1. 比较运算
## 比较运算

| 操作符名 | 功能描述 |
| :-------------- | :--------------------- |
Expand All @@ -37,7 +35,7 @@
| `ILIKE` | 模糊匹配, 大小写不敏感 |
| `RLIKE` | 正则表达式匹配 |

### 2. 逻辑运算
## 逻辑运算

| 操作符名 | 功能描述 |
| :---------- | :------- |
Expand All @@ -46,7 +44,7 @@
| `XOR` | 逻辑与或 |
| `NOT`, `!` | 逻辑非, unary operator |

### 3. 算术运算
## 算术运算

| 操作符名 | 功能描述 |
| :--------- | :------------------------------------------------------- |
Expand All @@ -59,7 +57,7 @@
| `+` | Unary plus |
| `-` | Unary minus, 只支持数值型操作数-number |

### 4. 位运算
## 位运算

| 操作符名 | Description |
| :------- | :---------- |
Expand All @@ -68,7 +66,7 @@
| `^` | Bitwise XOR |
| `~` | Bitwise NOT, unary operator |

### 5. 类型运算和函数
## 类型运算和函数

| 操作符名 | Description |
| :------------- | :--------------------------------------------------------- |
Expand Down Expand Up @@ -97,7 +95,7 @@ SELECT INT(1.2);

X:表示从原类型转换为目标类型的转换是不支持的

| src\|dist | bool | smallint | int | float | int64 | double | timestamp | date | string |
| src\|dst | bool | smallint | int | float | int64 | double | timestamp | date | string |
| :------------ | :----- | :------- | :----- | :----- | :----- | :----- | :-------- | :----- | :----- |
| **bool** | Safe | Safe | Safe | Safe | Safe | Safe | UnSafe | X | Safe |
| **smallint** | UnSafe | Safe | Safe | Safe | Safe | Safe | UnSafe | X | Safe |
Expand All @@ -115,14 +113,13 @@ X:表示从原类型转换为目标类型的转换是不支持的
| :------- | :------------------------ |
| `=` | 赋值 (可用于 SET 语句中 ) |

## 表达式
## 条件表达式

- CASE WHEN
```sql
SELECT case 'bb' when 'aa' then 'apple' else 'nothing' end; -- SIMPLE CASE WHEN
SELECT case
when 'bb'='aa' then 'apple'
when 'bb'='bb' then 'banana'
else 'nothing'
end; -- SEARCHED CASE WHEN
```
### CASE 表达式
```sql
SELECT case 'bb' when 'aa' then 'apple' else 'nothing' end; -- SIMPLE CASE WHEN
SELECT case
when 'bb'='aa' then 'apple'
when 'bb'='bb' then 'banana'
else 'nothing' end; -- SEARCHED CASE WHEN
```

0 comments on commit a1fb0e4

Please sign in to comment.