I want to autogenerate sequence for a primary key field as a custom Id with auto-increment properties. For example, Id list should be like [P001, P002, P003…]. How can I generate this from normal Id column or otherwise?
CREATE TABLE `product` ( `id` integer NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(45) DEFAULT NULL };
I have checked and found out solutions to do so in SQL. But I need to know the MySQL workaround for this.
My situation is similar to this question, but it doesn’t work on MySQL.
How to create a custom auto generated ID number for a primary key column?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
You can achieve this by creating a TRIGGER.
Check out this question/answer How to make MySQL table primary key auto increment with some prefix