In my table (MySQL) I have these fields:
id
- primary, auto_increment
hash
- base 36 representation of id
I'd like to populate both fields at once, using a stored procedure to compute the base 36 equivalent of the value id receives on INSERT. Something like this:
INSERT into `urls` (`id`,`hash`) VALUES (NULL,base36(`id`));
Obviously this doesn't work, but I hope it illustrates what I'm trying to achieve. Is this possible, and if so, how?
Note: I want to use only one query, so last_insert_id isn't helpful (at least as I understand).