0

I have a table with the following field values:

enter image description here

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?

2
  • 2
    That's a horrible database design. Do you have a chance to fix this before you continue? Commented Nov 12, 2021 at 15:02
  • yes I can change that, what do you recommend me? Appreciate it Commented Nov 12, 2021 at 16:23

1 Answer 1

1

You can convert the string into an array:

SELECT templateid 
FROM public.templates 
WHERE 'Yes' = any(string_to_array(keyword, ','))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.