0

I am new to MYSQL. I have a requirement to split a string into rows based on the delimiter given by the user. User might give any delimiter and any number of times.

For Ex:

Input:

'ABC,DEF;GHI@JKL-MNO/PQR&STU)VWX?YZ'

Output:

ABC
DEF
GHI
JKL
MNO
PQR
STU
VWX
YZ

Note: I am able to do the same requirement in SQL Server. But I am not able to convert the same to MYSQL Code. If anyone can convert it to mysql, please let me know I will share the code.

Please help me. Thanks in advance.

Vahid Farahmandian
  • 6,081
  • 7
  • 42
  • 62
  • 4
    show us your `sql server` code – Mahedi Sabuj Jun 19 '16 at 15:09
  • Please find the code snippet here: http://madprops.org/blog/splitting-text-into-words-in-sql-revisited/ It is working fine for my requirement. But I could not get the equivalent functions for CHARINDEX AND PATINDEX in MYSQL. – venkatesh pardhu Jun 19 '16 at 15:13
  • Here is `CharIndex` equivalent in MySQL: http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_instr – Mahedi Sabuj Jun 19 '16 at 15:36
  • 1
    there are a couple of functions in the code (`COUNT_IN_SET` and `VALUE_IN_SET`) that may be be useful? maybe interesting? : Example code: [SQLFiddle](http://sqlfiddle.com/#!9/7f279/1). The question: [Can I resolve this with pure mysql? (joining on ';' separated values in a column)](http://stackoverflow.com/a/33806675/3184785) – Ryan Vincent Jun 19 '16 at 16:08
  • 1
    Possible duplicate of [Can I resolve this with pure mysql? (joining on ';' separated values in a column)](http://stackoverflow.com/questions/33782728/can-i-resolve-this-with-pure-mysql-joining-on-separated-values-in-a-column) – Norbert Jun 19 '16 at 17:36

0 Answers0