'increment via trigger varchar value in the column
please help to solve one problem - I need to create after insert in table row with incremented value
| id | number |
|---|---|
| 1 | inc1 |
| 2 | inc2 |
I need to insert inc3 in number column automatically. How to do that?
Solution 1:[1]
Solved! Created a before insert trigger:
BEFORE INSERT ON `incident` FOR EACH ROW set NEW.`number` = CONCAT('INC' , (LPAD ((SELECT incident.sys_id from incident ORDER BY sys_id DESC LIMIT 1), 6, '0')))
this got a previous id and concat it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andronicus |
