Skip to content

Instantly share code, notes, and snippets.

@ano
Created February 15, 2020 05:56
Show Gist options
  • Save ano/4ca2421a7d6ab430906ef970923aabd7 to your computer and use it in GitHub Desktop.
Save ano/4ca2421a7d6ab430906ef970923aabd7 to your computer and use it in GitHub Desktop.
MySQL Convert UUID to Integer
/*
The format for converting UUID's to integers is as follows
CONV(LEFT(HEX(`uuid_from_bin` (`uuid_v5` (<a static uuid value>,<the uuid field>))),8),16,10) AS id
MYSQL User Defined Functions
uuid_from_bin
and uuid_v5
can be found here https://gist.github.com/ano/60b20726124ffa38571d44cedac61b5d
*/
CONV(LEFT(HEX(`uuid_from_bin` (`uuid_v5` ('dd9e93cf-4d32-4f42-9573-7a9989a48e54',`FID`))),8),16,10) AS id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment