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
STARTS_WITH predicate
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
STARTS_WITH predicates allow for finding strings by a common, fixed prefix.
Unlike the LIKE predicate (which can be used to emulate this), no wildcards are supported and the prefix must be matched exactly.
With jOOQ, the STARTS_WITH predicate can be created from any column expression as such:
STARTS_WITH(TITLE, 'abc')
BOOK.TITLE.startsWith("abc")
Dialect support
This example using jOOQ:
BOOK.TITLE.startsWith("abc")
Translates to the following dialect specific expressions:
ASE
BOOK.TITLE LIKE (str_replace(
str_replace(
str_replace('abc', '!', '!!'),
'%',
'!%'
),
'_',
'!_'
) || '%') ESCAPE '!'
Aurora MySQL, MariaDB, MySQL
BOOK.TITLE LIKE concat(
replace(
replace(
replace('abc', '!', '!!'),
'%',
'!%'
),
'_',
'!_'
),
'%'
) ESCAPE '!'
Aurora Postgres, CockroachDB, Firebird, H2, HSQLDB, Hana, Informix, Oracle, Postgres, SQLite, Sybase, Vertica
BOOK.TITLE LIKE (replace(
replace(
replace('abc', '!', '!!'),
'%',
'!%'
),
'_',
'!_'
) || '%') ESCAPE '!'
BigQuery
strpos(BOOK.TITLE, 'abc') = 1
ClickHouse
startsWith(BOOK.TITLE, 'abc')
Databricks
startswith(BOOK.TITLE, 'abc')
DB2
BOOK.TITLE LIKE CAST((replace(
replace(
replace('abc', '!', '!!'),
'%',
'!%'
),
'_',
'!_'
) || '%') AS VARCHAR(4000)) ESCAPE '!'
DuckDB, Spanner, Trino
starts_with(BOOK.TITLE, 'abc')
SQLDataWarehouse
charindex('abc', BOOK.TITLE) = 1
SQLServer
BOOK.TITLE LIKE (replace(
replace(
replace('abc', '!', '!!'),
'%',
'!%'
),
'_',
'!_'
) + '%') ESCAPE '!'
Access, Exasol, MemSQL, Redshift, Snowflake, Teradata, YugabyteDB
/* UNSUPPORTED */
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!