Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for OCT() #16959

Merged
merged 6 commits into from
Apr 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions functions-and-operators/string-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1180,11 +1180,52 @@ Negation of simple pattern matching.

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

Negation of `REGEXP`.
Negation of [`REGEXP`](#regexp).

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

Return a string containing octal representation of a number.
Return a string containing octal (base 7) representation of a number.
dveeden marked this conversation as resolved.
Show resolved Hide resolved

Examples:

In the example below you can see that the decimal values 1 to 7 are identical to the octal numbers. The numbers 8 until 15 in decimal match with 10 to 17 octal.
dveeden marked this conversation as resolved.
Show resolved Hide resolved

```sql
WITH RECURSIVE nr(n) AS (
SELECT 1 AS n
dveeden marked this conversation as resolved.
Show resolved Hide resolved
UNION ALL
SELECT n+1 FROM nr WHERE n<20
)
SELECT n, OCT(n) FROM nr;
```

```
+------+--------+
| n | OCT(n) |
+------+--------+
| 1 | 1 |
dveeden marked this conversation as resolved.
Show resolved Hide resolved
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
| 7 | 7 |
| 8 | 10 |
| 9 | 11 |
| 10 | 12 |
| 11 | 13 |
| 12 | 14 |
| 13 | 15 |
| 14 | 16 |
| 15 | 17 |
| 16 | 20 |
| 17 | 21 |
| 18 | 22 |
| 19 | 23 |
| 20 | 24 |
+------+--------+
20 rows in set (0.00 sec)
```

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

Expand Down
Loading