diff --git a/functions-and-operators/bit-functions-and-operators.md b/functions-and-operators/bit-functions-and-operators.md index 78cb52f893c7e..3e54cf75e4919 100644 --- a/functions-and-operators/bit-functions-and-operators.md +++ b/functions-and-operators/bit-functions-and-operators.md @@ -20,7 +20,7 @@ TiDB supports all of the [bit functions and operators](https://dev.mysql.com/doc | [`<<`](#-left-shift) | Left shift | | [`>>`](#-right-shift) | Right shift | -## [`BIT_COUNT()`](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#function_bit-count) +## `BIT_COUNT()` The `BIT_COUNT(expr)` function returns the number of bits that are set as 1 in `expr`. @@ -71,7 +71,7 @@ SELECT BIT_COUNT(INET_ATON('255.255.255.0')); 1 row in set (0.00 sec) ``` -## [`&` (bitwise AND)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-and) +## `&` (bitwise AND) The `&` operator performs a bitwise AND operation. It compares the corresponding bits of two numbers: if both corresponding bits are 1, the corresponding bit of the result is 1; otherwise, it is 0. @@ -129,7 +129,7 @@ SELECT INET_NTOA(INET_ATON('192.168.1.2') & INET_ATON('255.255.255.0')); 1 row in set (0.00 sec) ``` -## [`~` (bitwise inversion)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-invert) +## `~` (bitwise inversion) The `~` operator performs a bitwise inversion (or bitwise NOT) operation on a given value. It inverts each bit of the given value: bits that are 0 become 1, and bits that are 1 become 0. @@ -169,7 +169,7 @@ SELECT CONV(~ b'1111111111111111111111111111111111111111111111110000111100001111 1 row in set (0.00 sec) ``` -## [`|` (bitwise OR)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-or) +## `|` (bitwise OR) The `|` operator performs a bitwise OR operation. It compares the corresponding bits of two numbers: if at least one of the corresponding bits is 1, the corresponding bit in the result is 1. @@ -197,7 +197,7 @@ SELECT CONV(b'1010' | b'1100',10,2); 1 row in set (0.00 sec) ``` -## [`^` (bitwise XOR)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-xor) +## `^` (bitwise XOR) The `^` operator performs a bitwise XOR (exclusive OR) operation. It compares the corresponding bits of two numbers: if the corresponding bits are different, the corresponding bit in the result is 1. @@ -227,7 +227,7 @@ SELECT CONV(b'1010' ^ b'1100',10,2); Note that the result is shown as `110` instead of `0110` because the leading zero is removed. -## [`<<` (left shift)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_left-shift) +## `<<` (left shift) The `<<` operator performs a left shift operation, which shifts the bits of a number to the left by a specified number of positions, filling the vacated bits with zeros on the right. @@ -261,7 +261,7 @@ SELECT n,1<>` (right shift)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_right-shift) +## `>>` (right shift) The `>>` operator performs a right shift operation, which shifts the bits of a number to the right by a specified number of positions, filling the vacated bits with zeros on the left. diff --git a/functions-and-operators/encryption-and-compression-functions.md b/functions-and-operators/encryption-and-compression-functions.md index 1bb01cfda4b46..dbf83ee5fca9b 100644 --- a/functions-and-operators/encryption-and-compression-functions.md +++ b/functions-and-operators/encryption-and-compression-functions.md @@ -26,7 +26,7 @@ TiDB supports most of the [encryption and compression functions](https://dev.mys | [`UNCOMPRESSED_LENGTH()`](#uncompressed_length) | Return the length of a string before compression | | [`VALIDATE_PASSWORD_STRENGTH()`](#validate_password_strength) | Validate the password strength | -### [`AES_DECRYPT()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-decrypt) +### `AES_DECRYPT()` The `AES_DECRYPT(data, key [,iv])` function decrypts `data` that was previously encrypted using the [`AES_ENCRYPT()`](#aes_encrypt) function with the same `key`. @@ -47,7 +47,7 @@ SELECT AES_DECRYPT(0x28409970815CD536428876175F1A4923, 'secret'); 1 row in set (0.00 sec) ``` -### [`AES_ENCRYPT()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-encrypt) +### `AES_ENCRYPT()` The `AES_ENCRYPT(data, key [,iv])` function encrypts `data` with `key` using the [Advanced Encryption Standard (AES)](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) algorithm. @@ -68,7 +68,7 @@ SELECT AES_ENCRYPT(0x616263,'secret'); 1 row in set (0.00 sec) ``` -### [`COMPRESS()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_compress) +### `COMPRESS()` The `COMPRESS(expr)` function returns a compressed version of the input data `expr`. @@ -122,7 +122,7 @@ SELECT LENGTH(a),LENGTH(COMPRESS(a)) FROM x; 1 row in set (0.00 sec) ``` -### [`MD5()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_md5) +### `MD5()` The `MD5(expr)` function calculates a 128-bit [MD5](https://en.wikipedia.org/wiki/MD5) hash for the given argument `expr`. @@ -139,7 +139,7 @@ SELECT MD5('abc'); 1 row in set (0.00 sec) ``` -### [`PASSWORD()`](https://dev.mysql.com/doc/refman/5.7/en/encryption-functions.html#function_password) +### `PASSWORD()` > **Warning:** > @@ -162,7 +162,7 @@ SELECT PASSWORD('secret'); Warning (Code 1681): PASSWORD is deprecated and will be removed in a future release. ``` -### [`RANDOM_BYTES()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_random-bytes) +### `RANDOM_BYTES()` The `RANDOM_BYTES(n)` function returns `n` random bytes. @@ -179,11 +179,11 @@ SELECT RANDOM_BYTES(3); 1 row in set (0.00 sec) ``` -### [`SHA()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1) +### `SHA()` The `SHA()` function is an alias for [`SHA1`](#sha1). -### [`SHA1()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1) +### `SHA1()` The `SHA1(expr)` function calculates a 160-bit [SHA-1](https://en.wikipedia.org/wiki/SHA-1) hash for the given argument `expr`. @@ -200,7 +200,7 @@ SELECT SHA1('abc'); 1 row in set (0.00 sec) ``` -### [`SHA2()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha2) +### `SHA2()` The `SHA2(str, n)` function calculates a hash using an algorithm from the [SHA-2](https://en.wikipedia.org/wiki/SHA-2) family. The `n` argument is used to select the algorithm. `SHA2()` returns `NULL` if any of the arguments are `NULL` or if the algorithm selected by `n` is unknown or unsupported. @@ -248,7 +248,7 @@ SELECT SM3('abc'); 1 row in set (0.00 sec) ``` -### [`UNCOMPRESS()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompress) +### `UNCOMPRESS()` The `UNCOMPRESS(data)` function decompresses the data that was compressed with the [`COMPRESS()`](#compress) function. @@ -265,7 +265,7 @@ SELECT UNCOMPRESS(0x03000000789C72747206040000FFFF018D00C7); 1 row in set (0.00 sec) ``` -### [`UNCOMPRESSED_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompressed-length) +### `UNCOMPRESSED_LENGTH()` The `UNCOMPRESSED_LENGTH(data)` function returns the first 4 bytes of the compressed data, which store the length that the compressed string had before being compressed with the [`COMPRESS()`](#compress) function. @@ -282,7 +282,7 @@ SELECT UNCOMPRESSED_LENGTH(0x03000000789C72747206040000FFFF018D00C7); 1 row in set (0.00 sec) ``` -### [`VALIDATE_PASSWORD_STRENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_validate-password-strength) +### `VALIDATE_PASSWORD_STRENGTH()` diff --git a/functions-and-operators/json-functions/json-functions-aggregate.md b/functions-and-operators/json-functions/json-functions-aggregate.md index e564119bc4feb..406fbbd300c87 100644 --- a/functions-and-operators/json-functions/json-functions-aggregate.md +++ b/functions-and-operators/json-functions/json-functions-aggregate.md @@ -7,7 +7,7 @@ summary: Learn about JSON functions that aggregate JSON values. The functions listed on this page are part of the [aggregate functions](/functions-and-operators/aggregate-group-by-functions.md) that TiDB supports, but are specific to working with JSON. -## [JSON_ARRAYAGG()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-arrayagg) +## JSON_ARRAYAGG() The `JSON_ARRAYAGG(key)` function aggregates values of keys into a JSON array according to the given `key`. `key` is typically an expression or a column name. @@ -28,7 +28,7 @@ SELECT JSON_ARRAYAGG(v) FROM (SELECT 1 'v' UNION SELECT 2); 1 row in set (0.00 sec) ``` -## [JSON_OBJECTAGG()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-objectagg) +## JSON_OBJECTAGG() The `JSON_OBJECTAGG(key,value)` function aggregates keys and values of keys into a JSON object according to the given `key` and `value`. Both `key` or `value` are typically an expression or a column name. diff --git a/functions-and-operators/json-functions/json-functions-create.md b/functions-and-operators/json-functions/json-functions-create.md index cbe0eb79761ea..21c4b9b4e04e1 100644 --- a/functions-and-operators/json-functions/json-functions-create.md +++ b/functions-and-operators/json-functions/json-functions-create.md @@ -7,7 +7,7 @@ summary: Learn about JSON functions that create JSON values. This document describes JSON functions that create JSON values. -## [JSON_ARRAY()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-array) +## JSON_ARRAY() The `JSON_ARRAY([val[, val] ...])` function evaluates a (possibly empty) list of values and returns a JSON array containing those values. @@ -24,7 +24,7 @@ SELECT JSON_ARRAY(1,2,3,4,5), JSON_ARRAY("foo", "bar"); 1 row in set (0.00 sec) ``` -## [JSON_OBJECT()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-object) +## JSON_OBJECT() The `JSON_OBJECT([key, val[, key, val] ...])` function evaluates a (possibly empty) list of key-value pairs and returns a JSON object containing those pairs. @@ -41,7 +41,7 @@ SELECT JSON_OBJECT("database", "TiDB", "distributed", TRUE); 1 row in set (0.00 sec) ``` -## [JSON_QUOTE()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-quote) +## JSON_QUOTE() The `JSON_QUOTE(str)` function returns a string as a JSON value with quotes. diff --git a/functions-and-operators/json-functions/json-functions-modify.md b/functions-and-operators/json-functions/json-functions-modify.md index 4d839a5efc7d3..0c4b5a017421c 100644 --- a/functions-and-operators/json-functions/json-functions-modify.md +++ b/functions-and-operators/json-functions/json-functions-modify.md @@ -7,11 +7,11 @@ summary: Learn about JSON functions that modify JSON values. This document describes JSON functions that modify JSON values. -## [JSON_APPEND()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-append) +## JSON_APPEND() An alias to [`JSON_ARRAY_APPEND()`](#json_array_append). -## [JSON_ARRAY_APPEND()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-array-append) +## JSON_ARRAY_APPEND() The `JSON_ARRAY_APPEND(json_array, path, value [,path, value] ...)` function appends values to the end of the indicated arrays within a JSON document at the specified `path` and returns the result. @@ -49,7 +49,7 @@ SELECT JSON_ARRAY_APPEND('{"transport_options": ["Car", "Boat", "Train"]}', '$.t 1 row in set (0.00 sec) ``` -## [JSON_ARRAY_INSERT()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-array-insert) +## JSON_ARRAY_INSERT() The `JSON_ARRAY_INSERT(json_array, path, value [,path, value] ...)` function inserts a `value` into the specified position of the `json_array` in the `path` and returns the result. @@ -87,7 +87,7 @@ SELECT JSON_ARRAY_INSERT('["Car", "Boat", "Train"]', '$[1]', "Airplane") AS "Tra 1 row in set (0.00 sec) ``` -## [JSON_INSERT()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-insert) +## JSON_INSERT() The `JSON_INSERT(json_doc, path, value [,path, value] ...)` function inserts one or more values into a JSON document and returns the result. @@ -125,7 +125,7 @@ SELECT JSON_INSERT('{"a": 61, "b": 62}', '$.a', 41, '$.c', 63); 1 row in set (0.00 sec) ``` -## [JSON_MERGE_PATCH()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge-patch) +## JSON_MERGE_PATCH() The `JSON_MERGE_PATCH(json_doc, json_doc [,json_doc] ...)` function merges two or more JSON documents into a single JSON document, without preserving values of duplicate keys. For `json_doc` arguments with duplicated keys, only the values from the later specified `json_doc` argument are preserved in the merged result. @@ -150,7 +150,7 @@ SELECT JSON_MERGE_PATCH( 1 row in set (0.00 sec) ``` -## [JSON_MERGE_PRESERVE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge-preserve) +## JSON_MERGE_PRESERVE() The `JSON_MERGE_PRESERVE(json_doc, json_doc [,json_doc] ...)` function merges two or more JSON documents while preserving all values associated with each key and returns the merged result. @@ -171,7 +171,7 @@ SELECT JSON_MERGE_PRESERVE('{"a": 1, "b": 2}','{"a": 100}', '{"c": 300}'); 1 row in set (0.00 sec) ``` -## [JSON_MERGE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge) +## JSON_MERGE() > **Warning:** > @@ -179,7 +179,7 @@ SELECT JSON_MERGE_PRESERVE('{"a": 1, "b": 2}','{"a": 100}', '{"c": 300}'); A deprecated alias for [`JSON_MERGE_PRESERVE()`](#json_merge_preserve). -## [JSON_REMOVE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-remove) +## JSON_REMOVE() The `JSON_REMOVE(json_doc, path [,path] ...)` function removes data of the specified `path` from a JSON document and returns the result. @@ -215,7 +215,7 @@ SELECT JSON_REMOVE('{"a": 61, "b": 62, "c": 63}','$.b','$.c'); 1 row in set (0.00 sec) ``` -## [JSON_REPLACE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-replace) +## JSON_REPLACE() The `JSON_REPLACE(json_doc, path, value [, path, value] ...)` function replaces values in specified paths of a JSON document and returns the result. If a specified path does not exist, the value corresponding to the path is not added to the result. @@ -253,7 +253,7 @@ SELECT JSON_REPLACE('{"a": 41, "b": 62}','$.b',42,'$.c',43); 1 row in set (0.00 sec) ``` -## [JSON_SET()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-set) +## JSON_SET() The `JSON_SET(json_doc, path, value [,path, value] ...)` function inserts or updates data in a JSON document and returns the result. @@ -291,7 +291,7 @@ SELECT JSON_SET('{"version": 1.1, "name": "example"}','$.version',1.2,'$.branch' 1 row in set (0.00 sec) ``` -## [JSON_UNQUOTE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-unquote) +## JSON_UNQUOTE() The `JSON_UNQUOTE(json)` function unquotes a JSON value and returns the result as a string. This is the opposite of the [`JSON_QUOTE()`](/functions-and-operators/json-functions/json-functions-create.md#json_quote) function. diff --git a/functions-and-operators/json-functions/json-functions-return.md b/functions-and-operators/json-functions/json-functions-return.md index cc4afd41a04fe..db7ef7847740d 100644 --- a/functions-and-operators/json-functions/json-functions-return.md +++ b/functions-and-operators/json-functions/json-functions-return.md @@ -7,7 +7,7 @@ summary: Learn about JSON functions that return JSON values. This document describes JSON functions that return JSON values. -## [JSON_DEPTH()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-depth) +## JSON_DEPTH() The `JSON_DEPTH(json_doc)` function returns the maximum depth of a JSON document. @@ -32,7 +32,7 @@ SELECT JSON_DEPTH('{"weather": {"current": "sunny"}}'); 1 row in set (0.00 sec) ``` -## [JSON_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-length) +## JSON_LENGTH() The `JSON_LENGTH(json_doc [,path])` function returns the length of a JSON document. If a `path` argument is given, it returns the length of the value within the path. @@ -68,7 +68,7 @@ SELECT JSON_LENGTH('{"weather": {"current": "sunny", "tomorrow": "cloudy"}}','$. 1 row in set (0.01 sec) ``` -## [JSON_TYPE()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-type) +## JSON_TYPE() The `JSON_TYPE(json_val)` function returns a string indicating [the type of a JSON value](/data-type-json.md#json-value-types). @@ -132,7 +132,7 @@ SELECT JSON_TYPE('"2025-06-14"'),JSON_TYPE(CAST(CAST('2025-06-14' AS date) AS js 1 row in set (0.00 sec) ``` -## [JSON_VALID()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-valid) +## JSON_VALID() The `JSON_VALID(str)` function checks if the argument is valid JSON. This can be useful for checking a column before converting it to the `JSON` type. diff --git a/functions-and-operators/json-functions/json-functions-search.md b/functions-and-operators/json-functions/json-functions-search.md index 89e0d13877dfe..33cb8ea8fb7e7 100644 --- a/functions-and-operators/json-functions/json-functions-search.md +++ b/functions-and-operators/json-functions/json-functions-search.md @@ -7,7 +7,7 @@ summary: Learn about JSON functions that search JSON values. This document describes JSON functions that search JSON values. -## [JSON_CONTAINS()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains) +## JSON_CONTAINS() By returning `1` or `0`, the `JSON_CONTAINS(json_doc, candidate [,path])` function indicates whether a given `candidate` JSON document is contained within a target JSON document. @@ -88,7 +88,7 @@ SELECT JSON_CONTAINS('{"foo": "bar", "aaa": 5}','"bar"', '$.foo'); 1 row in set (0.00 sec) ``` -## [JSON_CONTAINS_PATH()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains-path) +## JSON_CONTAINS_PATH() The `JSON_CONTAINS_PATH(json_doc, all_or_one, path [,path, ...])` function returns `0` or `1` to indicate whether a JSON document contains data at a given path or paths. @@ -139,7 +139,7 @@ SELECT JSON_CONTAINS_PATH('{"foo": "bar", "aaa": 5}','all','$.foo', '$.aaa'); 1 row in set (0.00 sec) ``` -## [JSON_EXTRACT()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-extract) +## JSON_EXTRACT() The `JSON_EXTRACT(json_doc, path[, path] ...)` function extracts data from a JSON document, selected from the parts of the document matched by the `path` arguments. @@ -156,7 +156,7 @@ SELECT JSON_EXTRACT('{"foo": "bar", "aaa": 5}', '$.foo'); 1 row in set (0.00 sec) ``` -## [->](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#operator_json-column-path) +## -> The `column->path` function returns the data in `column` that matches the `path` argument. It is an alias for [`JSON_EXTRACT()`](#json_extract). @@ -179,7 +179,7 @@ FROM ( 1 row in set (0.00 sec) ``` -## [->>](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#operator_json-inline-path) +## ->> The `column->>path` function unquotes data in `column` that matches the `path` argument. It is an alias for `JSON_UNQUOTE(JSON_EXTRACT(doc, path_literal))`. @@ -204,7 +204,7 @@ FROM ( 1 row in set (0.00 sec) ``` -## [JSON_KEYS()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-keys) +## JSON_KEYS() The `JSON_KEYS(json_doc [,path])` function returns the top-level keys of a JSON object as a JSON array. If a `path` argument is given, it returns the top-level keys from the selected path. @@ -240,7 +240,7 @@ SELECT JSON_KEYS('{"name": {"first": "John", "last": "Doe"}, "type": "Person"}', 1 row in set (0.00 sec) ``` -## [JSON_SEARCH()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-search) +## JSON_SEARCH() The `JSON_SEARCH(json_doc, one_or_all, str)` function searches a JSON document for one or all matches of a string. @@ -276,7 +276,7 @@ SELECT JSON_SEARCH('{"a": ["aa", "bb", "cc"], "b": ["cc", "dd"]}','all','cc'); 1 row in set (0.01 sec) ``` -## [MEMBER OF()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#operator_member-of) +## MEMBER OF() The `str MEMBER OF (json_array)` function tests if the passed value `str` is an element of the `json_array`, it returns `1`. Otherwise, it returns `0`. It returns `NULL` if any of the arguments is `NULL`. @@ -294,7 +294,7 @@ SELECT '๐Ÿ' MEMBER OF ('["๐Ÿ","๐Ÿฅฅ","๐Ÿฅญ"]') AS 'Contains pineapple'; ``` -## [JSON_OVERLAPS()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-overlaps) +## JSON_OVERLAPS() The `JSON_OVERLAPS(json_doc, json_doc)` function indicates whether two JSON documents have overlapping part. If yes, it returns `1`. If not, it returns `0`. It returns `NULL` if any of the arguments is `NULL`. diff --git a/functions-and-operators/json-functions/json-functions-utility.md b/functions-and-operators/json-functions/json-functions-utility.md index 4f0c0c27eb04e..a83c75e0f3193 100644 --- a/functions-and-operators/json-functions/json-functions-utility.md +++ b/functions-and-operators/json-functions/json-functions-utility.md @@ -7,7 +7,7 @@ summary: Learn about JSON utility functions. This document describes JSON utility functions. -## [JSON_PRETTY()](https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-pretty) +## JSON_PRETTY() The `JSON_PRETTY(json_doc)` function does pretty formatting of a JSON document. @@ -29,7 +29,7 @@ JSON_PRETTY('{"person":{"name":{"first":"John","last":"Doe"},"age":23}}'): { 1 row in set (0.00 sec) ``` -## [JSON_STORAGE_FREE()](https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-storage-free) +## JSON_STORAGE_FREE() The `JSON_STORAGE_FREE(json_doc)` function returns how much storage space is freed in the binary representation of the JSON value after it is updated in place. @@ -50,7 +50,7 @@ SELECT JSON_STORAGE_FREE('{}'); 1 row in set (0.00 sec) ``` -## [JSON_STORAGE_SIZE()](https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-storage-size) +## JSON_STORAGE_SIZE() The `JSON_STORAGE_SIZE(json_doc)` function returns an approximate size of bytes required to store the JSON value. Because the size does not account for TiKV using compression, the output of this function is not strictly compatible with MySQL. diff --git a/functions-and-operators/json-functions/json-functions-validate.md b/functions-and-operators/json-functions/json-functions-validate.md index 3f233c798f0c2..c91748d1f19a4 100644 --- a/functions-and-operators/json-functions/json-functions-validate.md +++ b/functions-and-operators/json-functions/json-functions-validate.md @@ -11,7 +11,7 @@ This document describes JSON functions that validate JSON documents. > > Currently, this feature is not available on [{{{ .starter }}}](https://docs.pingcap.com/tidbcloud/select-cluster-tier#tidb-cloud-serverless) and [{{{ .essential }}}](https://docs.pingcap.com/tidbcloud/select-cluster-tier#essential) clusters. -## [JSON_SCHEMA_VALID()](https://dev.mysql.com/doc/refman/8.0/en/json-validation-functions.html#function_json-schema-valid) +## JSON_SCHEMA_VALID() The `JSON_SCHEMA_VALID(schema, json_doc)` function validate a JSON document against a schema to ensure data integrity and consistency. diff --git a/functions-and-operators/string-functions.md b/functions-and-operators/string-functions.md index 9f1ef27a07c0d..335a223aaa2bc 100644 --- a/functions-and-operators/string-functions.md +++ b/functions-and-operators/string-functions.md @@ -16,7 +16,7 @@ For comparisons between functions and syntax of Oracle and TiDB, see [Comparison ## Supported functions -### [`ASCII()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ascii) +### `ASCII()` The `ASCII(str)` function is used to get the ASCII value of the leftmost character in the given argument. The argument can be either a string or a number. @@ -44,7 +44,7 @@ Output: +------------+---------------+-----------+ ``` -### [`BIN()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_bin) +### `BIN()` The `BIN()` function is used to convert the given argument into a string representation of its binary value. The argument can be either a string or a number. @@ -87,7 +87,7 @@ Output 2: +------------------------------------------------------------------+ ``` -### [`BIT_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_bit-length) +### `BIT_LENGTH()` The `BIT_LENGTH()` function is used to return the length of a given argument in bits. @@ -132,7 +132,7 @@ SELECT CustomerName, BIT_LENGTH(CustomerName) AS BitLengthOfName FROM Customers; > > The preceding example operates under the assumption that there is a database with a table named `Customers` and a column inside the table named `CustomerName`. -### [`CHAR()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char) +### `CHAR()` The `CHAR()` function is used to get the corresponding character of a specific ASCII value. It performs the opposite operation of `ASCII()`, which returns the ASCII value of a specific character. If multiple arguments are supplied, the function works on all arguments and are then concatenated together. @@ -201,7 +201,7 @@ SELECT CHAR(65,66,67); 1 row in set (0.00 sec) ``` -### [`CHAR_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char-length) +### `CHAR_LENGTH()` The `CHAR_LENGTH()` function is used to get the total number of characters in a given argument as an integer. @@ -232,11 +232,11 @@ SELECT CustomerName, CHAR_LENGTH(CustomerName) AS LengthOfName FROM Customers; > > The preceding example operates under the assumption that there is a database with a table named `Customers` and a column inside the table named `CustomerName`. -### [`CHARACTER_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_character-length) +### `CHARACTER_LENGTH()` The `CHARACTER_LENGTH()` function is the same as the `CHAR_LENGTH()` function. Both functions can be used synonymously because they generate the same output. -### [`CONCAT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat) +### `CONCAT()` The `CONCAT()` function concatenates one or more arguments into a single string. @@ -298,7 +298,7 @@ Output: +-------------+ ``` -### [`CONCAT_WS()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat-ws) +### `CONCAT_WS()` The `CONCAT_WS()` function is a form of [`CONCAT()`](#concat) with a separator, which returns a string concatenated by the specified separator. @@ -417,7 +417,7 @@ Output: +-----------------------------------------+ ``` -### [`ELT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_elt) +### `ELT()` The `ELT()` function returns the element at the index number. @@ -436,7 +436,7 @@ SELECT ELT(3, 'This', 'is', 'TiDB'); The preceding example returns the third element, which is `'TiDB'`. -### [`EXPORT_SET()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_export-set) +### `EXPORT_SET()` The `EXPORT_SET()` function returns a string that consists of a specified number (`number_of_bits`) of `on`/`off` values, optionally separated by `separator`. These values are based on whether the corresponding bit in the `bits` argument is `1`, where the first value corresponds to the rightmost (lowest) bit of `bits`. @@ -499,7 +499,7 @@ SELECT EXPORT_SET(b'01010101', 'x', '_', '', 8); 1 row in set (0.00 sec) ``` -### [`FIELD()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_field) +### `FIELD()` Return the index (position) of the first argument in the subsequent arguments. @@ -515,7 +515,7 @@ SELECT FIELD('needle', 'A', 'needle', 'in', 'a', 'haystack'); 1 row in set (0.00 sec) ``` -### [`FIND_IN_SET()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_find-in-set) +### `FIND_IN_SET()` Return the index position of the first argument within the second argument. @@ -533,7 +533,7 @@ SELECT FIND_IN_SET('Go', 'COBOL,BASIC,Rust,Go,Java,Fortran'); 1 row in set (0.00 sec) ``` -### [`FORMAT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_format) +### `FORMAT()` The `FORMAT(X,D[,locale])` function is used to format the number `X` to a format similar to `"#,###,###. ##"`, rounded to `D` decimal places, and return the result as a string. @@ -583,7 +583,7 @@ mysql> SELECT FORMAT(12.36, 2); +------------------+ ``` -### [`FROM_BASE64()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_from-base64) +### `FROM_BASE64()` The `FROM_BASE64()` function is used to decode a [Base64](https://datatracker.ietf.org/doc/html/rfc4648) encoded string and return the decoded result in its hexadecimal form. @@ -630,7 +630,7 @@ mysql> SELECT FROM_BASE64('MTIzNDU2'); +--------------------------------------------------+ ``` -### [`HEX()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex) +### `HEX()` The `HEX()` function is used to convert the given argument into a string representation of its hexadecimal value. The argument can be either a string or a number. @@ -680,7 +680,7 @@ SELECT HEX(NULL); +-----------+ ``` -### [`INSERT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_insert) +### `INSERT()` The `INSERT(str, pos, len, newstr)` function is used to replace a substring in `str` (that starts at position `pos` and is `len` characters long) with the string `newstr`. This function is multibyte safe. @@ -744,7 +744,7 @@ SELECT INSERT('ใ‚ใ‚ใ‚ใ‚ใ‚ใ‚ใ‚', 2, 3, 'xx'); +---------------------------------------------+ ``` -### [`INSTR()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_instr) +### `INSTR()` The `INSTR(str, substr)` function is used to get the position of the first occurrence of `substr` in `str`. Each argument can be either a string or a number. This function is the same as the two-argument version of [`LOCATE(substr, str)`](#locate), but with the order of the arguments reversed. @@ -808,11 +808,11 @@ SELECT INSTR(0123, "12"); +-------------------+ ``` -### [`LCASE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_lcase) +### `LCASE()` The `LCASE(str)` function is a synonym for [`LOWER(str)`](#lower), which returns the lowercase of the given argument. -### [`LEFT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_left) +### `LEFT()` The `LEFT()` function returns a specified number of characters from the left side of a string. @@ -887,7 +887,7 @@ SELECT LEFT(NULL, 3); +------------------------------+ ``` -### [`LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_length) +### `LENGTH()` The `LENGTH()` function returns the length of a string in bytes. @@ -929,7 +929,7 @@ SELECT LENGTH(NULL); +--------------+ ``` -### [`LIKE`](https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like) +### `LIKE` The `LIKE` operator is used for simple string matching. The expression `expr LIKE pat [ESCAPE 'escape_char']` returns `1` (`TRUE`) or `0` (`FALSE`). If either `expr` or `pat` is `NULL`, the result is `NULL`. @@ -1066,7 +1066,7 @@ SELECT '๐Ÿฃ๐ŸบSushi๐Ÿฃ๐Ÿบ' COLLATE utf8mb4_unicode_ci LIKE '%SUSHI%' AS resu +--------+ ``` -### [`LOCATE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_locate) +### `LOCATE()` The `LOCATE(substr, str[, pos])` function is used to get the position of the first occurrence of a specified substring `substr` in a string `str`. The `pos` argument is optional and specifies the starting position for the search. @@ -1245,7 +1245,7 @@ SELECT LOCATE(_binary'B', 'aBcde'); +-----------------------------+ ``` -### [`LOWER()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_lower) +### `LOWER()` The `LOWER(str)` function is used to convert all characters in the given argument `str` to lowercase. The argument can be either a string or a number. @@ -1275,7 +1275,7 @@ SELECT LOWER(-012); +-------------+ ``` -### [`LPAD()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_lpad) +### `LPAD()` The `LPAD(str, len, padstr)` function returns the string argument, left-padded with the specified string `padstr` to a length of `len` characters. @@ -1315,7 +1315,7 @@ SELECT LPAD('TiDB',-2,'>'); 1 row in set (0.00 sec) ``` -### [`LTRIM()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ltrim) +### `LTRIM()` The `LTRIM()` function removes leading spaces from a given string. @@ -1357,7 +1357,7 @@ SELECT CONCAT('ยซ',LTRIM(' hello'),'ยป'); 1 row in set (0.00 sec) ``` -### [`MAKE_SET()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_make-set) +### `MAKE_SET()` The `MAKE_SET()` function returns a set of comma-separated strings based on whether a corresponding bit in the `bits` argument is set to `1`. @@ -1447,7 +1447,7 @@ SELECT MAKE_SET(b'111','foo','bar','baz'); 1 row in set (0.0002 sec) ``` -### [`MID()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_mid) +### `MID()` The `MID(str, pos[, len])` function returns a substring starting from the specified `pos` position with the `len` length. @@ -1487,7 +1487,7 @@ SELECT MID('abcdef',2); 1 row in set (0.00 sec) ``` -### [`NOT LIKE`](https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_not-like) +### `NOT LIKE` Negation of simple pattern matching. @@ -1525,11 +1525,11 @@ SELECT 'aaa' LIKE 'b%', 'aaa' NOT LIKE 'b%'; 1 row in set (0.00 sec) ``` -### [`NOT REGEXP`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_not-regexp) +### `NOT REGEXP` Negation of [`REGEXP`](#regexp). -### [`OCT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_oct) +### `OCT()` Return a string containing [octal](https://en.wikipedia.org/wiki/Octal) (base 8) representation of a number. @@ -1575,11 +1575,11 @@ SELECT n, OCT(n) FROM nr; 20 rows in set (0.00 sec) ``` -### [`OCTET_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_octet-length) +### `OCTET_LENGTH()` Synonym for [`LENGTH()`](#length). -### [`ORD()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ord) +### `ORD()` Return the character code for the leftmost character of the given argument. @@ -1632,11 +1632,11 @@ SELECT ORD('e'), ORD('รซ'), HEX('e'), HEX('รซ'); 1 row in set (0.00 sec) ``` -### [`POSITION()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_position) +### `POSITION()` Synonym for [`LOCATE()`](#locate). -### [`QUOTE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_quote) +### `QUOTE()` Escape the argument for use in an SQL statement. @@ -1661,7 +1661,7 @@ SELECT QUOTE(0x002774657374); 1 row in set (0.00 sec) ``` -### [`REGEXP`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp) +### `REGEXP` Pattern matching using regular expressions. @@ -1720,7 +1720,7 @@ WHERE 1 row in set (0.01 sec) ``` -### [`REGEXP_INSTR()`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-instr) +### `REGEXP_INSTR()` Return the starting index of the substring that matches the regular expression (Partly compatible with MySQL. For more details, see [Regular expression compatibility with MySQL](#regular-expression-compatibility-with-mysql)). @@ -1859,7 +1859,7 @@ SELECT REGEXP_INSTR('abcabc','A' COLLATE utf8mb4_bin); 1 row in set (0.00 sec) ``` -### [`REGEXP_LIKE()`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-like) +### `REGEXP_LIKE()` Whether the string matches the regular expression (Partly compatible with MySQL. For more details, see [Regular expression compatibility with MySQL](#regular-expression-compatibility-with-mysql)). @@ -1912,7 +1912,7 @@ SELECT REGEXP_LIKE('abc','^A','i'); 1 row in set (0.00 sec) ``` -### [`REGEXP_REPLACE()`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-replace) +### `REGEXP_REPLACE()` Replace substrings that match the regular expression (Partly compatible with MySQL. For more details, see [Regular expression compatibility with MySQL](#regular-expression-compatibility-with-mysql)). @@ -2006,7 +2006,7 @@ SELECT REGEXP_REPLACE('TooDB', 'O{2}','i',1,1,'i'); 1 row in set (0.00 sec) ``` -### [`REGEXP_SUBSTR()`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-substr) +### `REGEXP_SUBSTR()` Return the substring that matches the regular expression (Partly compatible with MySQL. For more details, see [Regular expression compatibility with MySQL](#regular-expression-compatibility-with-mysql)). @@ -2027,7 +2027,7 @@ SELECT REGEXP_SUBSTR('This is TiDB','Ti.{2}'); 1 row in set (0.00 sec) ``` -### [`REPEAT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_repeat) +### `REPEAT()` Repeat a string the specified number of times. @@ -2087,47 +2087,47 @@ SELECT REPEAT('ha',3); 1 row in set (0.00 sec) ``` -### [`REPLACE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_replace) +### `REPLACE()` Replace occurrences of a specified string. -### [`REVERSE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_reverse) +### `REVERSE()` Reverse the characters in a string. -### [`RIGHT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_right) +### `RIGHT()` Return the specified rightmost number of characters. -### [`RLIKE`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp) +### `RLIKE` Synonym for [`REGEXP`](#regexp). -### [`RPAD()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_rpad) +### `RPAD()` Append string the specified number of times. -### [`RTRIM()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_rtrim) +### `RTRIM()` Remove trailing spaces. -### [`SPACE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_space) +### `SPACE()` Return a string of the specified number of spaces. -### [`STRCMP()`](https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#function_strcmp) +### `STRCMP()` Compare two strings. -### [`SUBSTR()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substr) +### `SUBSTR()` Return the substring as specified. -### [`SUBSTRING()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring) +### `SUBSTRING()` Return the substring as specified. -### [`SUBSTRING_INDEX()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring-index) +### `SUBSTRING_INDEX()` The `SUBSTRING_INDEX()` function is used to extract a substring from a string based on a specified delimiter and count. This function is particularly useful when dealing with data separated by a specific delimiter, such as parsing CSV data or processing log files. @@ -2176,7 +2176,7 @@ Output 2: +------------------------------------------+ ``` -### [`TO_BASE64()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_to-base64) +### `TO_BASE64()` The `TO_BASE64()` function is used to convert the given argument to a string in the base-64 encoded form and return the result according to the character set and collation of the current connection. A base-64 encoded string can be decoded using the [`FROM_BASE64()`](#from_base64) function. @@ -2221,15 +2221,15 @@ Output 2: +--------------+ ``` -### [`TRANSLATE()`](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/TRANSLATE.html#GUID-80F85ACB-092C-4CC7-91F6-B3A585E3A690) +### `TRANSLATE()` Replace all occurrences of characters by other characters in a string. It does not treat empty strings as `NULL` as Oracle does. -### [`TRIM()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_trim) +### `TRIM()` Remove leading and trailing spaces. -### [`UCASE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ucase) +### `UCASE()` The `UCASE()` function is used to convert a string to uppercase letters. This function is equivalent to the `UPPER()` function. @@ -2253,7 +2253,7 @@ Output: +--------------+-------------+ ``` -### [`UNHEX()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_unhex) +### `UNHEX()` The `UNHEX()` function performs the reverse operation of the `HEX()` function. It treats each pair of characters in the argument as a hexadecimal number and converts it to the character represented by that number, returning the result as a binary string. @@ -2278,7 +2278,7 @@ Output: +--------------------------------------+ ``` -### [`UPPER()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_upper) +### `UPPER()` The `UPPER()` function is used to convert a string to uppercase letters. This function is equivalent to the `UCASE()` function. @@ -2302,7 +2302,7 @@ Output: +--------------+-------------+ ``` -### [`WEIGHT_STRING()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_weight-string) +### `WEIGHT_STRING()` The `WEIGHT_STRING()` function returns the weight string (binary characters) for the input string, primarily used for sorting and comparison operations in multi-character set scenarios. If the argument is `NULL`, it returns `NULL`. The syntax is as follows: diff --git a/functions-and-operators/window-functions.md b/functions-and-operators/window-functions.md index ebb35d207739c..d534be8cc2999 100644 --- a/functions-and-operators/window-functions.md +++ b/functions-and-operators/window-functions.md @@ -32,7 +32,7 @@ Except for `GROUP_CONCAT()` and `APPROX_PERCENTILE()`, TiDB supports using all [ | [`RANK()`](#rank) | Returns the rank of the current row within the partition. The rank might have gaps. | | [`ROW_NUMBER()`](#row_number) | Returns the number of the current row in the partition. | -## [`CUME_DIST()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_cume-dist) +## `CUME_DIST()` `CUME_DIST()` calculates the cumulative distribution of a value within a group of values. Note that you need to use the `ORDER BY` clause with `CUME_DIST()` to sort the group of values. Otherwise, this function will not return the expected values. @@ -66,7 +66,7 @@ FROM 4 rows in set (0.00 sec) ``` -## [`DENSE_RANK()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_dense-rank) +## `DENSE_RANK()` The `DENSE_RANK()` function returns the rank of the current row. It is similar to [`RANK()`](#rank) but does not leave any gaps in case of ties (rows that share the same values and order conditions). @@ -102,7 +102,7 @@ FROM ( 6 rows in set (0.00 sec) ``` -## [`FIRST_VALUE()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_first-value) +## `FIRST_VALUE()` The `FIRST_VALUE(expr)` returns the first value in a window. @@ -141,7 +141,7 @@ ORDER BY 4 rows in set (0.00 sec) ``` -## [`LAG()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_lag) +## `LAG()` The `LAG(expr [, num [, default]])` function returns the value of `expr` from the row that is `num` rows preceding the current row. If such row does not exist, `default` is returned. By default, `num` is `1` and `default` is `NULL` when they are not specified. @@ -183,7 +183,7 @@ FROM 10 rows in set (0.01 sec) ``` -## [`LAST_VALUE()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_last-value) +## `LAST_VALUE()` The `LAST_VALUE()` function returns the last value in the window. @@ -226,7 +226,7 @@ ORDER BY 10 rows in set (0.00 sec) ``` -## [`LEAD()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_lead) +## `LEAD()` The `LEAD(expr [, num [,default]])` function returns the value of `expr` from the row that is `num` rows following the current row. If such row does not exist, `default` is returned. By default, `num` is `1` and `default` is `NULL` when they are not specified. @@ -269,7 +269,7 @@ FROM 10 rows in set (0.00 sec) ``` -## [`NTH_VALUE()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_nth-value) +## `NTH_VALUE()` The `NTH_VALUE(expr, n)` function returns the `n`-th value of the window. @@ -317,7 +317,7 @@ ORDER BY 10 rows in set (0.00 sec) ``` -## [`NTILE()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_ntile) +## `NTILE()` The `NTILE(n)` function divides the window into `n` groups and returns the group number of each row. @@ -360,7 +360,7 @@ FROM ``` -## [`PERCENT_RANK()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_percent-rank) +## `PERCENT_RANK()` The `PERCENT_RANK()` function returns a number between 0 and 1 indicating the percentage of rows with a value less than the value of the current row. @@ -397,7 +397,7 @@ FROM ( 6 rows in set (0.00 sec) ``` -## [`RANK()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_rank) +## `RANK()` The `RANK()` function is similar to [`DENSE_RANK()`](#dense_rank) but will leave gaps in case of ties (rows that share the same values and order conditions). This means it provides an absolute ranking. For example, a rank of 7 means that there are 6 rows with lower ranks. @@ -434,7 +434,7 @@ FROM ( 6 rows in set (0.00 sec) ``` -## [`ROW_NUMBER()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_row-number) +## `ROW_NUMBER()` The `ROW_NUMBER()` returns the row number of the current row in the result set.