Skip to main content
2 of 2
added 9 characters in body
McNets
  • 23.9k
  • 11
  • 50
  • 89

Postgres 9.2 allows you to use string_to_array and unnest, you can use it to get the desired result.

create table foo(id int, allowed_types varchar(256));
insert into foo values (1, '3,4,5,13,14');

1 rows affected

with a as
(
    select id, unnest(string_to_array(allowed_types, ',')) elem
    from foo
)
select id, string_agg(elem, ',')
from a 
where elem not in ('4','5')
group by id
id | string_agg
-: | :---------
 1 | 3,13,14   

dbfiddle here

McNets
  • 23.9k
  • 11
  • 50
  • 89