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
ENDS_WITH predicate
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
ENDS_WITH predicates allow for finding strings by a common, fixed suffix.
Unlike the LIKE predicate (which can be used to emulate this), no wildcards are supported and the suffix must be matched exactly.
With jOOQ, the ENDS_WITH predicate can be created from any column expression as such:
ENDS_WITH(TITLE, 'abc')
BOOK.TITLE.endsWith("abc")
Dialect support
This example using jOOQ:
BOOK.TITLE.endsWith("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') = ((char_length(BOOK.TITLE) - char_length('abc')) + 1)
ClickHouse
endsWith(BOOK.TITLE, 'abc')
Databricks
endswith(BOOK.TITLE, 'abc')
DB2
BOOK.TITLE LIKE CAST(('%' || replace(
replace(
replace('abc', '!', '!!'),
'%',
'!%'
),
'_',
'!_'
)) AS VARCHAR(4000)) ESCAPE '!'
DuckDB
suffix(BOOK.TITLE, 'abc')
Spanner
ends_with(BOOK.TITLE, 'abc')
SQLDataWarehouse
charindex('abc', BOOK.TITLE) = ((len(BOOK.TITLE) - len('abc')) + 1)
SQLServer
BOOK.TITLE LIKE ('%' + replace(
replace(
replace('abc', '!', '!!'),
'%',
'!%'
),
'_',
'!_'
)) ESCAPE '!'
Access, Exasol, MemSQL, Redshift, Snowflake, Teradata, Trino, 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!