Skip to content

Commit

Permalink
Add example for QUOTE() (pingcap#16958)
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden committed May 15, 2024
1 parent 349a67b commit 4e02ed7
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions functions-and-operators/string-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1292,20 +1292,41 @@ SELECT n, OCT(n) FROM nr;

### [`OCTET_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_octet-length)

Synonym for `LENGTH()`.
Synonym for [`LENGTH()`](#length).

### [`ORD()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ord)

Return character code for leftmost character of the argument.

### [`POSITION()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_position)

Synonym for `LOCATE()`.
Synonym for [`LOCATE()`](#locate).

### [`QUOTE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_quote)

Escape the argument for use in an SQL statement.

If the argument is `NULL`, the function returns `NULL`.

Example:

To display the result directly instead of showing a hexadecimal-encoded value, you need to start the MySQL client with the [`--skip-binary-as-hex`](https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex) option.

The following example shows that the ASCII NULL character is escaped as `\0` and the single quote character `'` is escaped as `\'`:

```sql
SELECT QUOTE(0x002774657374);
```

```
+-----------------------+
| QUOTE(0x002774657374) |
+-----------------------+
| '\0\'test' |
+-----------------------+
1 row in set (0.00 sec)
```

### [`REGEXP`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp)

Pattern matching using regular expressions.
Expand Down Expand Up @@ -1400,7 +1421,7 @@ Return the specified rightmost number of characters.

### [`RLIKE`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp)

Synonym for `REGEXP`.
Synonym for [`REGEXP`](#regexp).

### [`RPAD()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_rpad)

Expand Down

0 comments on commit 4e02ed7

Please sign in to comment.