I am using PostgreSQL with Laravel 8.
In a Postgres table, I have one comma separated character varying
column
I need those records from this table where value of this comma separated column is 43 OR 56 OR 252.
CodePudding user response:
Storing comma separated values in a single column is a huge mistake to begin with. But if you can't change the data model, you can achieve what you want by converting the value into an array, then use the array overlaps operator &&
with the values you want to test for:
select *
from the_table
where string_to_array(bad_column, ',')::int[] && array[43, 56, 252];