Answer the question
In order to leave comments, you need to log in
SELECT if present in column?
There is an 'index' column where values are stored as "1, 2, 3". How to make a query by type:
value = 1
SELECT * FROM index WHERE value is in the column?
I thought about WHERE index IN value, but I think I'm wrong
Answer the question
In order to leave comments, you need to log in
You need to read why relational bases are called relational and what normal forms are.
Doing what you need is not a problem in Postgres, there are even several ways. For example:
SELECT * FROM table WHERE value = ANY(string_to_array(index, ', ')::int[])
Pretty simple
create index my_table_index_index on my_schema.my_table using gin (cast(string_to_array(index, ', ') as int[]));
select *
from my_schema.my_table
where string_to_array(index, ', ')::int[] @> ARRAY [1, 2, 3]::int[];
select *
from my_schema.my_table
where cast(string_to_array(index, ', ') as int[]) @> cast(string_to_array(:param, ', ') as int[]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question