-
-
Save theking2/39a930277f5fe5c5f7a0c5dca297bb21 to your computer and use it in GitHub Desktop.
BIN_TO_UUID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION `BIN_TO_UUID`(b binary(16)) | |
RETURNS char(36) CHARSET ascii | |
BEGIN | |
DECLARE hexStr CHAR(32); | |
SET hexStr = HEX(b); | |
RETURN LOWER(CONCAT( | |
SUBSTR(hexStr, 25, 12), '-', | |
SUBSTR(hexStr, 21, 4), '-', | |
SUBSTR(hexStr, 13, 4), '-', | |
SUBSTR(hexStr, 17, 4), '-', | |
SUBSTR(hexStr, 1, 12) | |
)); | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment