From 2e685c7634a024f46be1df1708a10d9c2cd28c47 Mon Sep 17 00:00:00 2001 From: qw4990 Date: Mon, 16 Oct 2023 20:48:09 +0800 Subject: [PATCH 01/15] fixup --- sql-statements/sql-statement-select.md | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 6628d35a5478e..dee3fa6ad2ef3 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -117,6 +117,8 @@ TableSampleOpt ::= ## Examples +### SELECT + ```sql mysql> CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, c1 INT NOT NULL); Query OK, 0 rows affected (0.11 sec) @@ -158,6 +160,64 @@ mysql> SELECT AVG(s_quantity), COUNT(s_quantity) FROM stock; The above example uses data generated with `tiup bench tpcc prepare`. The first query shows the use of `TABLESAMPLE`. +### SELECT ... INTO OUTFILE + +`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. Column and line terminators can be specified to produce a specific output format. + +You can use the `Fields` and `Lines` parameters to specify how to handle the data format. + +- `FIELDS TERMINATED BY`: specifies the data delimiter. +- `FIELDS ENCLOSED BY`: specifies the enclosing character of the data. +- `LINES TERMINATED BY`: specifies the line terminator, if you want to end a line with a certain character. + +Below are some examples, first create a table and prepare some data: + +```sql +mysql> create table t (a int, b varchar(10), c decimal(10,2)); +Query OK, 0 rows affected (0.02 sec) + +mysql> insert into t values (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); +Query OK, 3 rows affected (0.01 sec) +``` + +Then here are some `SELECT ... INTO OUTFILE` statements and their results. + +```sql +mysql> select * from t into outfile '/tmp/tmp_file1'; +Query OK, 3 rows affected (0.00 sec) +``` + +``` +1 a 1.10 +2 b 2.20 +3 c 3.30 +``` + +```sql +mysql> select * from t into outfile '/tmp/tmp_file2' fields terminated by ',' enclosed by '"'; +Query OK, 3 rows affected (0.00 sec) +``` + +``` +"1","a","1.10" +"2","b","2.20" +"3","c","3.30" +``` + +```sql +mysql> select * from t into outfile '/tmp/tmp_file3' fields terminated by ',' enclosed by '\'' lines terminated by '<<<\n'; +Query OK, 3 rows affected (0.00 sec) +``` + +``` +'1','a','1.10'<<< +'2','b','2.20'<<< +'3','c','3.30'<<< +``` + + +Now `SELECT ... INTO @variable`, `SELECT ... INTO DUMPFILE` or any [external storage](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) like S3 or GCS is not supported. + ## MySQL compatibility - The syntax `SELECT ... INTO @variable` is not supported. From fda9352fa6c87917526c5c6e93825d197fb67592 Mon Sep 17 00:00:00 2001 From: qw4990 Date: Mon, 16 Oct 2023 20:50:20 +0800 Subject: [PATCH 02/15] fixup --- sql-statements/sql-statement-select.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index dee3fa6ad2ef3..e0c0657be71bc 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -215,7 +215,6 @@ Query OK, 3 rows affected (0.00 sec) '3','c','3.30'<<< ``` - Now `SELECT ... INTO @variable`, `SELECT ... INTO DUMPFILE` or any [external storage](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) like S3 or GCS is not supported. ## MySQL compatibility From 79f2867f7045789aefdf6fda47a0903f344952d4 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Tue, 17 Oct 2023 18:27:06 +0800 Subject: [PATCH 03/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index e0c0657be71bc..912f3b76be2c1 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -183,7 +183,7 @@ Query OK, 3 rows affected (0.01 sec) Then here are some `SELECT ... INTO OUTFILE` statements and their results. ```sql -mysql> select * from t into outfile '/tmp/tmp_file1'; +mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; Query OK, 3 rows affected (0.00 sec) ``` From 932d9a6a6f38dc2d720ceb771ca97ec54030561a Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Tue, 17 Oct 2023 18:27:17 +0800 Subject: [PATCH 04/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 912f3b76be2c1..6220088c225d9 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -162,7 +162,7 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first ### SELECT ... INTO OUTFILE -`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. Column and line terminators can be specified to produce a specific output format. +`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. Field and line terminators can be specified to produce a specific output format. Common output formats are comma separated (CSV) and tab separated (TSV). You can use the `Fields` and `Lines` parameters to specify how to handle the data format. From 369d32a1357e084280237b4ce83a8c9e0cfde32e Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Tue, 17 Oct 2023 18:40:49 +0800 Subject: [PATCH 05/15] Update sql-statements/sql-statement-select.md --- sql-statements/sql-statement-select.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 6220088c225d9..28f70e4d580c9 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -162,9 +162,7 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first ### SELECT ... INTO OUTFILE -`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. Field and line terminators can be specified to produce a specific output format. Common output formats are comma separated (CSV) and tab separated (TSV). - -You can use the `Fields` and `Lines` parameters to specify how to handle the data format. +`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. You can use the `Fields` and `Lines` parameters to specify how to handle the data format. Common output formats are comma separated (CSV) and tab separated (TSV). - `FIELDS TERMINATED BY`: specifies the data delimiter. - `FIELDS ENCLOSED BY`: specifies the enclosing character of the data. From d78fdf80221bf9297b5e8bb2279331cfb41cc8f4 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Wed, 18 Oct 2023 11:33:56 +0800 Subject: [PATCH 06/15] Update sql-statements/sql-statement-select.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-select.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 28f70e4d580c9..962fb51080914 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -178,7 +178,10 @@ mysql> insert into t values (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); Query OK, 3 rows affected (0.01 sec) ``` -Then here are some `SELECT ... INTO OUTFILE` statements and their results. +Here are some `SELECT ... INTO OUTFILE` statements and their results. + +Example 1: + ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; From 5242a18f6526f29b122586f9c41eaa2999dc2b7e Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Wed, 18 Oct 2023 11:34:01 +0800 Subject: [PATCH 07/15] Update sql-statements/sql-statement-select.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-select.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 962fb51080914..8cdb2bd3cfba9 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -188,6 +188,8 @@ mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; Query OK, 3 rows affected (0.00 sec) ``` +In this example, you can find the query result in `/tmp/tmp_file1` as follows: + ``` 1 a 1.10 2 b 2.20 From 7e9796110fe509547d9c4dd3f256f2e44a6cbfd6 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 30 Oct 2023 14:12:55 +0800 Subject: [PATCH 08/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 8cdb2bd3cfba9..74b855799ace5 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -171,12 +171,11 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first Below are some examples, first create a table and prepare some data: ```sql -mysql> create table t (a int, b varchar(10), c decimal(10,2)); +mysql> CREATE TABLE t (a INT, b VARCHAR(10), c DECIMAL(10,2)); Query OK, 0 rows affected (0.02 sec) -mysql> insert into t values (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); +mysql> INSERT INTO t VALUES (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); Query OK, 3 rows affected (0.01 sec) -``` Here are some `SELECT ... INTO OUTFILE` statements and their results. From 6217b37f12fad0b21f2eb087319da091bec862ab Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 30 Oct 2023 14:13:01 +0800 Subject: [PATCH 09/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 74b855799ace5..83c869da859ec 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -207,7 +207,8 @@ Query OK, 3 rows affected (0.00 sec) ``` ```sql -mysql> select * from t into outfile '/tmp/tmp_file3' fields terminated by ',' enclosed by '\'' lines terminated by '<<<\n'; +mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file3' + -> FIELDS TERMINATED BY ',' ENCLOSED BY '\'' LINES TERMINATED BY '<<<\n'; Query OK, 3 rows affected (0.00 sec) ``` From 1e2218e1b939856c07af27a5ae9a1bc7763193f5 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 30 Oct 2023 14:13:12 +0800 Subject: [PATCH 10/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 83c869da859ec..e46bd13d0bbc0 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -196,7 +196,7 @@ In this example, you can find the query result in `/tmp/tmp_file1` as follows: ``` ```sql -mysql> select * from t into outfile '/tmp/tmp_file2' fields terminated by ',' enclosed by '"'; +mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file2' FIELDS TERMINATED BY ',' ENCLOSED BY '"'; Query OK, 3 rows affected (0.00 sec) ``` From 8597d577c2bd3ced839aed4d68e8ef73263581ce Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Mon, 30 Oct 2023 15:34:06 +0800 Subject: [PATCH 11/15] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index e46bd13d0bbc0..1673fda6cea2f 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -176,12 +176,12 @@ Query OK, 0 rows affected (0.02 sec) mysql> INSERT INTO t VALUES (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); Query OK, 3 rows affected (0.01 sec) +``` Here are some `SELECT ... INTO OUTFILE` statements and their results. Example 1: - ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; Query OK, 3 rows affected (0.00 sec) From 24b4fe9496f4a3fdc53fe519c84b1380b5d308f7 Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Mon, 30 Oct 2023 15:55:09 +0800 Subject: [PATCH 12/15] Apply suggestions from code review --- sql-statements/sql-statement-select.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 1673fda6cea2f..4ddcf67c6da73 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -162,13 +162,13 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first ### SELECT ... INTO OUTFILE -`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. You can use the `Fields` and `Lines` parameters to specify how to handle the data format. Common output formats are comma separated (CSV) and tab separated (TSV). +The `SELECT ... INTO OUTFILE` statement is used to write the result of a query to a file. You can use the `Fields` and `Lines` parameters to specify the data format of the output file. Common output formats include comma-separated values (CSV) and tab-separated values (TSV). - `FIELDS TERMINATED BY`: specifies the data delimiter. - `FIELDS ENCLOSED BY`: specifies the enclosing character of the data. - `LINES TERMINATED BY`: specifies the line terminator, if you want to end a line with a certain character. -Below are some examples, first create a table and prepare some data: +Assume that there is a table `t` with three columns as follows: ```sql mysql> CREATE TABLE t (a INT, b VARCHAR(10), c DECIMAL(10,2)); @@ -195,23 +195,31 @@ In this example, you can find the query result in `/tmp/tmp_file1` as follows: 3 c 3.30 ``` +Example 2: + ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file2' FIELDS TERMINATED BY ',' ENCLOSED BY '"'; Query OK, 3 rows affected (0.00 sec) ``` +In this example, you can find the query result in `/tmp/tmp_file2` as follows: + ``` "1","a","1.10" "2","b","2.20" "3","c","3.30" ``` +Example 3: + ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file3' -> FIELDS TERMINATED BY ',' ENCLOSED BY '\'' LINES TERMINATED BY '<<<\n'; Query OK, 3 rows affected (0.00 sec) ``` +In this example, you can find the query result in `/tmp/tmp_file3` as follows: + ``` '1','a','1.10'<<< '2','b','2.20'<<< From 1300a9d2a3b11b44baa055431c13dad59c75329e Mon Sep 17 00:00:00 2001 From: qiancai Date: Mon, 30 Oct 2023 16:48:43 +0800 Subject: [PATCH 13/15] refine the descriptions --- sql-statements/sql-statement-select.md | 31 ++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 4ddcf67c6da73..b36f355e8f392 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -13,10 +13,6 @@ The `SELECT` statement is used to read data from TiDB. ![SelectStmt](/media/sqlgram/SelectStmt.png) -> **Note:** -> -> The `SELECT ... INTO OUTFILE` statement is only applicable to TiDB Self-Hosted and not available on [TiDB Cloud](https://docs.pingcap.com/tidbcloud/). - **FromDual:** ![FromDual](/media/sqlgram/FromDual.png) @@ -162,11 +158,19 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first ### SELECT ... INTO OUTFILE -The `SELECT ... INTO OUTFILE` statement is used to write the result of a query to a file. You can use the `Fields` and `Lines` parameters to specify the data format of the output file. Common output formats include comma-separated values (CSV) and tab-separated values (TSV). +The `SELECT ... INTO OUTFILE` statement is used to write the result of a query to a file. + +> **Note:** +> +> - This statement is only applicable to TiDB Self-Hosted and not available on [TiDB Cloud](https://docs.pingcap.com/tidbcloud/). +> - This statement does not support +writing query results to any [external storages](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) such as Amazon S3 or GCS. -- `FIELDS TERMINATED BY`: specifies the data delimiter. -- `FIELDS ENCLOSED BY`: specifies the enclosing character of the data. -- `LINES TERMINATED BY`: specifies the line terminator, if you want to end a line with a certain character. +In the statement, you can specify the format of the output file by using the following clauses: + +- `FIELDS TERMINATED BY`: specifies the field delimiter in the file. For example, you can specify it as `','` to output comma-separated values (CSV) or `'\t'` to output tab-separated values (TSV). +- `FIELDS ENCLOSED BY`: specifies the enclosing character that wraps around each field in the file. +- `LINES TERMINATED BY`: specifies the line terminator in the file, if you want to end a line with a certain character. Assume that there is a table `t` with three columns as follows: @@ -178,9 +182,9 @@ mysql> INSERT INTO t VALUES (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); Query OK, 3 rows affected (0.01 sec) ``` -Here are some `SELECT ... INTO OUTFILE` statements and their results. +The following examples show how to use the `SELECT ... INTO OUTFILE` statement to write the query result to a file. -Example 1: +**Example 1:** ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; @@ -195,7 +199,7 @@ In this example, you can find the query result in `/tmp/tmp_file1` as follows: 3 c 3.30 ``` -Example 2: +**Example 2:** ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file2' FIELDS TERMINATED BY ',' ENCLOSED BY '"'; @@ -210,7 +214,7 @@ In this example, you can find the query result in `/tmp/tmp_file2` as follows: "3","c","3.30" ``` -Example 3: +**Example 3:** ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file3' @@ -226,11 +230,10 @@ In this example, you can find the query result in `/tmp/tmp_file3` as follows: '3','c','3.30'<<< ``` -Now `SELECT ... INTO @variable`, `SELECT ... INTO DUMPFILE` or any [external storage](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) like S3 or GCS is not supported. - ## MySQL compatibility - The syntax `SELECT ... INTO @variable` is not supported. +- The syntax `SELECT ... INTO DUMPFILE` is not supported. - The syntax `SELECT .. GROUP BY expr` does not imply `GROUP BY expr ORDER BY expr` as it does in MySQL 5.7. TiDB instead matches the behavior of MySQL 8.0 and does not imply a default order. - The syntax `SELECT ... TABLESAMPLE ...` is a TiDB extension and not supported by MySQL. From 5f1941fa5ca90b1c6bb99b4f8d4ee7bea09486db Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Tue, 31 Oct 2023 17:54:14 +0800 Subject: [PATCH 14/15] Update sql-statements/sql-statement-select.md Co-authored-by: Ran --- sql-statements/sql-statement-select.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index b36f355e8f392..1c93ac1d3c857 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -163,8 +163,7 @@ The `SELECT ... INTO OUTFILE` statement is used to write the result of a query t > **Note:** > > - This statement is only applicable to TiDB Self-Hosted and not available on [TiDB Cloud](https://docs.pingcap.com/tidbcloud/). -> - This statement does not support -writing query results to any [external storages](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) such as Amazon S3 or GCS. +> - This statement does not support writing query results to any [external storages](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) such as Amazon S3 or GCS. In the statement, you can specify the format of the output file by using the following clauses: From 60be285d064f41dd24ac288316c0880ef5c6d83b Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Thu, 2 Nov 2023 15:55:44 +0800 Subject: [PATCH 15/15] Update sql-statements/sql-statement-select.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 1c93ac1d3c857..3c7a2321724f4 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -234,7 +234,7 @@ In this example, you can find the query result in `/tmp/tmp_file3` as follows: - The syntax `SELECT ... INTO @variable` is not supported. - The syntax `SELECT ... INTO DUMPFILE` is not supported. - The syntax `SELECT .. GROUP BY expr` does not imply `GROUP BY expr ORDER BY expr` as it does in MySQL 5.7. TiDB instead matches the behavior of MySQL 8.0 and does not imply a default order. -- The syntax `SELECT ... TABLESAMPLE ...` is a TiDB extension and not supported by MySQL. +- The syntax `SELECT ... TABLESAMPLE ...` is a TiDB extension designed for compatibility with other database systems and the [ISO/IEC 9075-2](https://standards.iso.org/iso-iec/9075/-2/ed-6/en/) standard, but currently it is not supported by MySQL. ## See also