Skip to content

Commit 8058d30

Browse files
authored
Merge pull request #9095 from soyeric128/select-exclude
docs: exclude parameter
2 parents e252083 + 9d9770c commit 8058d30

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

docs/doc/14-sql-commands/20-query-syntax/dml-select.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ SELECT
1111
[ALL | DISTINCT]
1212
select_expr [[AS] alias], ...
1313
[INTO variable [, ...]]
14-
[ FROM table_references
14+
[EXCLUDE (col_name1 [, col_name2, col_name3, ...] ) ]
15+
[FROM table_references
1516
[AT ...]
1617
[WHERE expr]
1718
[GROUP BY {{col_name | expr | col_alias | col_position}, ...
@@ -22,6 +23,7 @@ SELECT
2223
[OFFSET row_count]
2324
[IGNORE_RESULT]
2425
]
26+
]
2527
```
2628

2729
:::tip
@@ -41,6 +43,47 @@ SELECT number FROM numbers(3);
4143
+--------+
4244
```
4345

46+
### EXCLUDE Parameter
47+
48+
Excludes one or more columns by their names from the result. The parameter is usually used in conjunction with `SELECT * ...` to exclude a few columns from the result instead of retrieving them all.
49+
50+
```sql
51+
SELECT * FROM allemployees ORDER BY id;
52+
53+
---
54+
| id | firstname | lastname | gender |
55+
|----|-----------|----------|--------|
56+
| 1 | Ryan | Tory | M |
57+
| 2 | Oliver | Green | M |
58+
| 3 | Noah | Shuster | M |
59+
| 4 | Lily | McMent | F |
60+
| 5 | Macy | Lee | F |
61+
62+
-- Exclude the column "id" from the result
63+
SELECT * EXCLUDE id FROM allemployees;
64+
65+
---
66+
| firstname | lastname | gender |
67+
|-----------|----------|--------|
68+
| Noah | Shuster | M |
69+
| Ryan | Tory | M |
70+
| Oliver | Green | M |
71+
| Lily | McMent | F |
72+
| Macy | Lee | F |
73+
74+
-- Exclude the columns "id" and "lastname" from the result
75+
SELECT * EXCLUDE (id,lastname) FROM allemployees;
76+
77+
---
78+
| firstname | gender |
79+
|-----------|--------|
80+
| Oliver | M |
81+
| Ryan | M |
82+
| Lily | F |
83+
| Noah | M |
84+
| Macy | F |
85+
```
86+
4487
## FROM Clause
4588

4689
```sql

0 commit comments

Comments
 (0)