I have a problem generating var char ID in MySQL with repeating Sequence
Need Following Format....
ID Client ID Department
001-01 001 HR
001-02 001 AV
002-01 002 HR
002-02 002 HR
003-01 003 Accounts
i have use trigger to achieve generate three digit id but problem for repeating sequence
INSERT INTO sequencetable VALUES (NULL); SET NEW.ID = CONCAT(LPAD(new.clientID,'-',LAST_INSERT_ID(), 2, '0'));
this trigger work fine. and generate ID look like this
ID Client ID Department
001-01 001 HR
001-02 001 AV
002-03 002 HR
002-04 002 HR
003-05 003 Accounts
but we don't need this format we need previous Format because sequence is not Repeated