Skip to content

Commit

Permalink
Merge pull request #4687 from BohuTANG/doc-round3-not-in
Browse files Browse the repository at this point in the history
chore(doc): add in conditional function and subquery operator
  • Loading branch information
BohuTANG committed Apr 4, 2022
2 parents cf6da3e + a6be530 commit 32114a6
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 24 deletions.
46 changes: 46 additions & 0 deletions docs/doc/03-reference/02-functions/01-conditional-functions/in.md
@@ -0,0 +1,46 @@
---
title: IN
description: Tests whether the argument is or is not one of the members of an explicit list
---

Tests whether the argument is or is not one of the members of an explicit list.

## Syntax

```sql
<value> [ NOT ] IN ( <value1> , <value2> , ... )
```

## Arguments

| Arguments | Description |
| ----------- | ----------- |

## Return Type


## Examples

```sql
mysql> select * from numbers(10) where number in (0, 1, 2, 3);
+--------+
| number |
+--------+
| 0 |
| 1 |
| 2 |
| 3 |
+--------+

mysql> select * from numbers(10) where number not in (0, 1, 2, 3);
+--------+
| number |
+--------+
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
+--------+
```
7 changes: 7 additions & 0 deletions docs/doc/03-reference/03-sql/02-dml/_category_.json
@@ -0,0 +1,7 @@
{
"label": "DML Commands",
"link": {
"type": "generated-index",
"slug": "/reference/sql/dml"
}
}
4 changes: 0 additions & 4 deletions docs/doc/03-reference/03-sql/02-dml/_category_.yml

This file was deleted.

7 changes: 7 additions & 0 deletions docs/doc/03-reference/03-sql/03-query-syntax/_category_.json
@@ -0,0 +1,7 @@
{
"label": "Query Syntax",
"link": {
"type": "generated-index",
"slug": "/reference/sql/query-syntax"
}
}
4 changes: 0 additions & 4 deletions docs/doc/03-reference/03-sql/03-query/_category_.yml

This file was deleted.

@@ -0,0 +1,7 @@
{
"label": "Query Operators",
"link": {
"type": "generated-index",
"slug": "/reference/sql/query-operators"
}
}
@@ -0,0 +1,64 @@
---
title: Subquery Operators
description:
A subquery is a query nested within another query.
---

This topic provides reference information about the subquery operators supported in Databend.

A subquery is a query nested within another query.

## [ NOT ] EXISTS

An EXISTS subquery is a boolean expression that can appear in a WHERE clause:
* An EXISTS expression evaluates to TRUE if any rows are produced by the subquery.
* A NOT EXISTS expression evaluates to TRUE if no rows are produced by the subquery.

### Syntax

```sql
[ NOT ] EXISTS ( <query> )
```

:::note
* Correlated EXISTS subqueries are currently supported only in a WHERE clause.
:::

### Example

```sql
mysql> select number from numbers(10) where number>5 and exists(select number from numbers(5) where number>4);
Query OK, 0 rows affected
```
`select number from numbers(5) where number>4` no rows are produced, `exists(select number from numbers(5) where number>4)` is FALSE.

```sql
mysql> select number from numbers(10) where number>5 and exists(select number from numbers(5) where number>3);
+--------+
| number |
+--------+
| 6 |
| 7 |
| 8 |
| 9 |
+--------+
```

`EXISTS(SELECT NUMBER FROM NUMBERS(5) WHERE NUMBER>3)` is TRUE.

```sql
mysql> select number from numbers(10) where number>5 and not exists(select number from numbers(5) where number>4);
+--------+
| number |
+--------+
| 6 |
| 7 |
| 8 |
| 9 |
+--------+
```

`not exists(select number from numbers(5) where number>4)` is TRUE.



7 changes: 7 additions & 0 deletions docs/doc/03-reference/03-sql/04-show/_category_.json
@@ -0,0 +1,7 @@
{
"label": "SHOW Commands",
"link": {
"type": "generated-index",
"slug": "/reference/sql/show"
}
}
4 changes: 0 additions & 4 deletions docs/doc/03-reference/03-sql/04-show/_category_.yml

This file was deleted.

7 changes: 7 additions & 0 deletions docs/doc/03-reference/03-sql/05-kill/_category_.json
@@ -0,0 +1,7 @@
{
"label": "KILL Commands",
"link": {
"type": "generated-index",
"slug": "/reference/sql/kill"
}
}
4 changes: 0 additions & 4 deletions docs/doc/03-reference/03-sql/05-kill/_category_.yml

This file was deleted.

7 changes: 7 additions & 0 deletions docs/doc/03-reference/03-sql/06-list/_category_.json
@@ -0,0 +1,7 @@
{
"label": "LIST Commands",
"link": {
"type": "generated-index",
"slug": "/reference/sql/list"
}
}
4 changes: 0 additions & 4 deletions docs/doc/03-reference/03-sql/06-list/_category_.yml

This file was deleted.

7 changes: 7 additions & 0 deletions docs/doc/03-reference/03-sql/07-system-tables/_category_.json
@@ -0,0 +1,7 @@
{
"label": "System Tables",
"link": {
"type": "generated-index",
"slug": "/reference/sql/system-tables"
}
}
4 changes: 0 additions & 4 deletions docs/doc/03-reference/03-sql/07-system-tables/_category_.yml

This file was deleted.

1 comment on commit 32114a6

@vercel
Copy link

@vercel vercel bot commented on 32114a6 Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.