Automatically add letters before auto-increment fieild
Is it possible to add a letter before auto increment in MySQL. I have several tables in my database, some of which have a unique ID generated by auto-incrementing. I want to be able to distinguish between the auto-generated numbers by the letter in front.
This is not a feature that is absolutely necessary, but it will just make small tasks easier.
Unfortunately, you cannot do this. At least not in sql. The autoincrement field is of integer type, so adding a letter there violates the constraint.
You can take a look at the link below for some sort of solution to this problem.
MySQL auto-add plus alphanumeric expression in one column
I hope this helps you in the right direction.
source to share
The best answer probably depends on what you mean by alphanumeric identifier. Does the alpha part increase in some way, and if so, what are the rules for doing this? If the alpha part is static, then you don't even need it in the DB: just add it to the numeric id when printing it out (perhaps using [s] printf () or similar functions to add zeros to keep it fixed in length?). However, not knowing the full requirement, we all just speculate
source to share