0

I'm trying to get a solution to add a number to a string on insert to column in database if the string is duplicated.

For example, i have a table test with the unique column name. I want to, when running this code

INSERT INTO test (name) VALUES (example)
INSERT INTO test (name) VALUES (example)
INSERT INTO test (name) VALUES (example)

The values inserted turn out

  1. example
  2. example-1
  3. example-2

Is it possible to do this directly on the database or is it better to do it on the api (Node.JS) that connects to the database?

  • What have you tried so far? Where are you stuck? – Nico Haase Mar 16 '20 at 13:49
  • Here is probably the rigth answer : [MySQL Insert row, on duplicate: add suffix and re-insert](https://stackoverflow.com/questions/8219340/mysql-insert-row-on-duplicate-add-suffix-and-re-insert) It is an insertion with an addittion of a number to its value. – VirussInside Mar 16 '20 at 13:44

0 Answers0