I am trying to make a column in a mysql database that automatically increments by one but goes from 0-Z and then roll.
For example, 000, 001, 002, ..., 009, 00A, 00B, ..., 00Z, 010, ..., 0ZZ, ..., 100.
I would like the database to create a column through the auto incrementing field.
I have the following ideas:
- Create a column for each character that goes from 0-36, then automatically increment the row N (where N is the least significant digit) by 1. Then add a trigger for each column to add 1 to column N-1 when column N reaches 36 .
- Create a table with 36 rows, where each row contains the character 0-Z and pull the corresponding character from the table with the same transfer logic from the above
- Create a stored procedure to execute the corresponding logic from point 1
- Ask the actual program to generate the value and paste it into the table
- have a regular automatic incremental value and calculate the next value in the sequence (this is the least optimal, since it complicates the analysis by a person who is simply in the database).
I was hoping there was something elegant that would allow me to do this, as a built-in mechanism, to do this that I simply don’t know. I do not know about stored procedures / triggers, so help with it would be greatly appreciated. I think the easiest way would be to have a lookup table for characters, and when line 36 is reached, it will reset to 0 and then be wrapped to line N-1.
source
share