I'm trying to use IN operator in a text[] column. But I got this error message:
ERROR: operator does not exist: text = text[] Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Is it possible to use IN operator in this context? If not what should I use?
I've tried casting into json/jsonb, use ANY, or @> operator without success
Reproducible example:
CREATE TABLE visitor (name varchar(255), hobbies text[]);
CREATE TABLE hobbies(name varchar(255), id text);
INSERT INTO visitor (name, hobbies) VALUES ('sanghin', '{ida}');
INSERT INTO hobbies (name, id) VALUES ('sql', 'ida');
SELECT name FROM hobbies WHERE id IN (SELECT hobbies FROM visitor WHERE visitor.name = 'sanghin');