0

I am migrating some of my workflows from MySQL to MonetDB.

One thing that has hampered my progress so far is the lack of FIND_IN_SET functionality in MonetDB:

> SELECT FIND_IN_SET('b', 'a,b,c,d');
2

I was relying on this functionality for converting domain definitions between two alignments.

Any idea how I could get this function in MonetDB with reasonable performance?

ostrokach
  • 17,993
  • 11
  • 78
  • 90

1 Answers1

1

You could try using a regular expression. I recommended this to someone using MySQL who wanted to find more than one needle in a comma-delimited haystack, perhaps it could be adapted to MonetDB?

SELECT name FROM table WHERE CONCAT(',', DataID, ',') REGEXP ',(222|777|400),'
chris g
  • 1,088
  • 10
  • 18
  • Thanks for the answer. However, I need something that would give me the index of the query inside the target (note the returned value of `2` in my question). `REGEXP` does not do this... – ostrokach Dec 18 '16 at 01:06
  • 1
    Guess I only carried the ball part of the way. MonetDB uses pcre regex, which should, in theory, be able to tokenize all matches, but not return the specific index you're looking for. The main problem is, you would severely impact performance, which is not why you went with MonetDB. LOCATE() will return string position of a match, but not for multiples. Wish I could be of more assistance here. – chris g Dec 18 '16 at 07:15