Simple solution, obviously, but hopefully this will save someone the time that I just lost.
#Mysql uuid generator update#
UPDATE some_table SET some_field=REPLACE(some_field, '-', '')
![mysql uuid generator mysql uuid generator](https://community.wappler.io/uploads/default/original/3X/1/b/1b17e097d04b3f4c5647e3921b26713528425b7b.png)
To resolve this, I just split it into two queries: UPDATE some_table SET some_field=(SELECT uuid()) It seems when surrounding the subquery to generate a UUID with REPLACE, it only runs the UUID query once, which probably makes perfect sense as an optimization to much smarter developers than I, but it didn't to me. UPDATE some_table SET some_field=(REPLACE(SELECT uuid(), '-', '')) Doesn't matter how I situated the parentheses, the same thing happens. Then all the resulting values were the same (not subtly different - I quadruple checked with a GROUP BY some_field query). But when I tried this: UPDATE some_table SET some_field=(REPLACE((SELECT uuid()), '-', '')) The function return value and type are the same as the return value and type of its argument, but the function. I found the answer by Rakesh to be the simplest that worked well, except in cases where you want to strip the dashes.įor reference: UPDATE some_table SET some_field=(SELECT uuid()) This function is useful for GROUP BY queries when the ONLYFULLGROUPBY SQL mode is enabled, for cases when MySQL rejects a query that you know is valid for reasons that MySQL cannot determine. Just a minor addition to make as I ended up with a weird result when trying to modify the UUIDs as they were generated. I'm using MySQL Server version: 5.5.40-0+wheezy1 (Debian) Two calls to UUID() are expected to generate two different values, even if these. | Abeokuta | ab026fa6238e2ab7ee0d76a1351f116f | A UUID is designed as a number that is globally unique in space and time. It seems when surrounding the subquery to generate a UUID with REPLACE, it only runs the UUID.
![mysql uuid generator mysql uuid generator](https://i.ytimg.com/vi/j-PNEv941-U/maxresdefault.jpg)
#Mysql uuid generator how to#
MySQL > select city, id from CityPopCountry limit 10 UUID in PHP MySQL How to generate Unique Id Auto Generate Code UUID Auto Generate Universal Unique ID PHP MySQL Tutorial Github From Download : ht. If you want visibly different keys, try this: update CityPopCountry set id = (select md5(UUID())) The approved solution does create unique IDs but on first glance they look identical, only the first few characters differ.