I have a table with the following field values:
I want to do a select
where I can match a value from this keyword column. For example:
SELECT templateid FROM public.templates WHERE keyword='Yes'
I don't want to use LIKE
because in the case one of the comma-separated values is Yessy
then I will get a return and that's not correct.
It has to be an exact match of one of the comma separated values.
Any clue?
CodePudding user response:
You can convert the string into an array:
SELECT templateid
FROM public.templates
WHERE 'Yes' = any(string_to_array(keyword, ','))