I want it to match only if the number B is not inside a bigger number.
e.g. I dont want it to match this: A = "12345" B = 234
I want it to match this: A = "94, 234, 88" B = 234
I tried looking at postgresql documentation but I am quite lost.
I want it to match only if the number B is not inside a bigger number.
e.g. I dont want it to match this: A = "12345" B = 234
I want it to match this: A = "94, 234, 88" B = 234
I tried looking at postgresql documentation but I am quite lost.
2
Answers
Storing CSV data in the format
94, 234, 88
directly in your table is probably poor table design. A better design would be to store each CSV number as a separate record, e.g.Then, to search for
234
you would only need a query like the following:That being said, you could stick with your current design and use regular expressions to search for individual numbers:
Convert the column to an
int[]
then use the appropriate array operator:See live demo.
Wrapping the string in
{
}
is needed to create an array literal from a naked CSV.