0

I have a DB column that has entries like this:

  • "56/45/34"
  • "78/34/145"
  • "45"
  • "" (i.e. NULL)

I want to search for the rows that match a certain number - for example "45" would should return the first and third rows but not the second.

0

2 Answers 2

4

We can try using a regex approach here with word boundaries:

select col
from your_table
where col ~* '\y45\y';

enter image description here

Demo

Sign up to request clarification or add additional context in comments.

Comments

3

You can convert the delimited string to an array and then test the array

select *
from the_table
where '45' = any(string_to_array(the_column, '/'))

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.