Is there a function in postgres like contains
? that can be used in the where clause
to check , whether the string passed is contained in column?
You could use position()
for that. It returns zero if the substring is not found:
position(col2 in col1) <> 0
There are a bunch of ways of solving this:
Use like
, ilike
, and/or SIMILAR TO
along with ||. To handle columns, something like:
WHERE col1 ilike '%' || col2 || '%';
Use position as NPE's answer
You could also use regexp_matches
but that is more complex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With