Reputation: 57
I have the query select * from tbl where column like '%DEF%'
.
Would it be possible to use regular expression to have the characters before DEF
be the same as those in the end but in reverse?
An example matching result ASDEFSA
or TERDEFRET
?
Upvotes: 2
Views: 115
Reputation: 311103
This can be done with a combination of reverse
and replace
:
SELECT *
FROM tbl
WHERE col LIKE '%DEF%' AND
REPLACE(col, 'DEF', '') = REVERSE(REPLACE(col, 'DEF', ''))
Upvotes: 4