I'm trying to auto increment a varchar value. I'm getting as an exception. I want to do without triggers,procedures and function.
So any suggestions are welcome.
insert into idsdf(name,sid) values("JKL",concat("JKL",convert(id,char)));
The output is like this
id(auto_increment) name sid
1 JKL JKL0
It's pretty clear from the MySQL documentation that you can only use numeric columns as auto-incremented values. In fact if you poke around a bit you'll find this statement:
MySQL wrote:AUTO_INCREMENT applies only to integer and floating-point types.
So your hopes of no extra coding aren't going to come true.
If it was me I would aim for a solution where you had a proper auto-increment column and then build your "JKL1" value later. However I have no idea what your requirements are because you asked a question about a proposed solution and not a question about your actual problem. If you'd like to explain your requirements you might well get suggestions which solve your problem better than the idea you proposed here, I think.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads