I have the following table:
cs_id ; cs_values ; cs_desc --------------------------- 1; 'a,b,c'; 'one' 2; 'd,a'; 'two' 3; 'a,c'; 'three'
The cs_valies field contains various values, separated by commas. I would like to get all the "cs_id" in strings that contain a specific value in the "cs_values".
I used this expression:
SELECT cs_id, regexp_split_to_table(cs_values, '* , *') as splitted_value WHERE splitted_value = 'a'
I have some questions:
- Postgres does not like alias names in a
WHERE -clause. Or does anyone have an idea how to achieve this? - Does anyone have a better solution to solve this problem?
Thanks to everyone, I hope that I do not miss something extremely obvious.
source share