Good day everyone. There is a field in the table that contains records of the form:

10,12,415

those. numbers separated by commas. It is necessary to display a line of the form:

(10) (12) (415)

those. numbers wrap in brackets and commas removed. On php it was possible to divide the string into an array using explode and then using implode to glue everything back into the string as needed. Can anyone have an idea how to do this with a select query in mysql? Thank.

    1 answer 1

    You can do it with the help of CONCAT and REPLACE functions:

    SELECT CONCAT ('(', REPLACE (field, ',', ') ('), ')') FROM table

    • An interesting decision, even did not even think of this, now I will test it. Thank you)) - nerik