Reputation: 55
Is there a easy way to convert UUIDs from this format
5967ca5e6162317eb4a825dcdcde0aea
to this format?
5967ca5e-6162-317e-b4a8-25dcdcde0aea
with an MySQL Query? i need to convert over 1000 UUIDs
Upvotes: 5
Views: 3602
Reputation: 7612
Alternative solution
// MySQL 8.x
SET @x = '5967ca5e6162317eb4a825dcdcde0aea';
select BIN_TO_UUID(UUID_TO_BIN(@x))
Upvotes: 1
Reputation: 33935
SET @x = '5967ca5e6162317eb4a825dcdcde0aea';
SELECT CONCAT_WS('-',MID(@x,1,8),MID(@x,9,4),MID(@x,13,4),MID(@x,17,4),MID(@x,21,1000))n;
+--------------------------------------+
| n |
+--------------------------------------+
| 5967ca5e-6162-317e-b4a8-25dcdcde0aea |
+--------------------------------------+
Upvotes: 14