Skip to content

Commit af1710d

Browse files
committed
Update 01-query-select.md
1 parent d89105a commit af1710d

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

docs/en/sql-reference/10-sql-commands/20-query-syntax/01-query-select.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ title: SELECT
33
---
44
import FunctionDescription from '@site/src/components/FunctionDescription';
55

6-
<FunctionDescription description="Introduced or updated: v1.2.435"/>
6+
<FunctionDescription description="Introduced or updated: v1.2.690"/>
77

88
import DetailsWrap from '@site/src/components/DetailsWrap';
99

1010
Retrieves data from a table.
1111

12-
13-
1412
## Syntax
1513

1614
```sql
1715
[WITH]
1816
SELECT
1917
[ALL | DISTINCT]
2018
[ TOP <n> ]
21-
<select_expr> | <col_name> [[AS] <alias>] | $<col_position> [, ...] |
19+
<select_expr> | <col_name> [[AS] <alias>] | $<col_position> [, ...] | *
2220
COLUMNS <expr>
2321
[EXCLUDE (<col_name1> [, <col_name2>, <col_name3>, ...] ) ]
2422
[FROM table_references]
@@ -39,17 +37,6 @@ SELECT
3937

4038
## SELECT Clause
4139

42-
```sql
43-
SELECT number FROM numbers(3);
44-
+--------+
45-
| number |
46-
+--------+
47-
| 0 |
48-
| 1 |
49-
| 2 |
50-
+--------+
51-
```
52-
5340
### AS Keyword
5441

5542
In Databend, you can use the AS keyword to assign an alias to a column. This allows you to provide a more descriptive and easily understandable name for the column in both the SQL statement and the query result:
@@ -155,7 +142,7 @@ SELECT * EXCLUDE (id,lastname) FROM allemployees;
155142
| Macy | F |
156143
```
157144

158-
### COLUMNS
145+
### COLUMNS Keyword
159146

160147
The COLUMNS keyword provides a flexible mechanism for column selection based on literal regular expression patterns and lambda expressions.
161148

@@ -232,6 +219,27 @@ SELECT a, $2 FROM t1;
232219
+---+-------+
233220
```
234221

222+
### Retrieving All Columns
223+
224+
The `SELECT *` statement is used to retrieve all columns from a table or query result. It is a convenient way to fetch complete data sets without specifying individual column names.
225+
226+
This example returns all columns from my_table:
227+
228+
```sql
229+
SELECT * FROM my_table;
230+
```
231+
232+
Databend extends SQL syntax by allowing queries to start with `FROM <table>` without explicitly using `SELECT *`:
233+
```sql
234+
FROM my_table;
235+
```
236+
237+
This is equivalent to:
238+
239+
```sql
240+
SELECT * FROM my_table;
241+
```
242+
235243
## FROM Clause
236244

237245
The FROM clause in a SELECT statement specifies the source table or tables from which data will be queried. You can also improve code readability by placing the FROM clause before the SELECT clause, especially when managing a lengthy SELECT list or aiming to quickly identify the origins of selected columns.

0 commit comments

Comments
 (0)