Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11

SUBSTRING

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

SUBSTRING() 函数根据给定的起始位置和(可选)长度计算字符串的子字符串。另请参见 LEFT, RIGHT

SELECT
  substring('hello world', 7),
  substring('hello world', 7, 1);
create.select(
  substring("hello world", 7),
  substring("hello world", 7, 1)).fetch();

结果是

+-----------+-----------+
| substring | substring |
+-----------+-----------+
| world     | w         |
+-----------+-----------+
有关此函数的二进制版本,请参见 SUBSTRING (binary)

方言支持

此示例使用 jOOQ

substring(val("hello world"), 7)

翻译成以下特定方言的表达式

访问

mid('hello world', 7)

ASE, SQLDataWarehouse, SQLServer

substring('hello world', 7, 2147483647)

Aurora MySQL, Aurora Postgres, BigQuery, ClickHouse, CockroachDB, Databricks, DuckDB, Exasol, H2, HSQLDB, Hana, MariaDB, MemSQL, MySQL, Postgres, Redshift, Snowflake, Sybase, Trino, Vertica, YugabyteDB

substring('hello world', 7)

DB2, Derby, Informix, Oracle, SQLite

substr('hello world', 7)

Firebird, Teradata

substring('hello world' FROM 7)
使用 jOOQ 3.21 生成。早期 jOOQ 版本的支持可能有所不同。 在我们的网站上翻译您自己的 SQL

反馈

您对此页面有任何反馈吗? 我们很乐意听取您的意见!

The jOOQ Logo