A
A
Andrey Prenrek2021-03-08 15:18:33
Python
Andrey Prenrek, 2021-03-08 15:18:33

How to add data separated by commas in db?

How to add a value to db separated by commas, for example, there is a table in the database, and the number 123456 in the table, how to add another number 946428, so that it is like this: 123456, 946428?
So that there are separate numbers, as in the list.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-03-08
@rozhnev

Easily:

UPDATE tbl SET val = IF(val IS NULL, :new_val, CONCAT(val, ',', :new_val))

MariaDB fiddle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question