please am stuck here. i want to generate unique Id's with letters like
ROC200,ROC201 in this order.
please and to be able to save into the database and able to retrieve it.
i did one but because it was a string bringing it back from the data base was a
problem.
thanks
And can't you just use numeric primary keys and then prefix them in your
application with some product code? Generating unique string IDs is quite a
problem, mainly if they should be incremented. Consider you happen to have
multiple requests at the same time, you check what is the last ID, generate a
new one but another thread of your application has just done the same so you end
up with 2 same IDs.
If you really need GUIDs, I'd create a trigger and let the database itself to
assign them. I tried to find some solution for you but it's apparently not a
common approach so you'd have to come up with a solution by yourself.
There is the uuid() MySQL function which generates something like this:
aab5d5fd-70c1-11e5-a4fb-b026b977eb28
Maybe you could use this or go with prefixed numeric IDs.