I’m trying to SELECT
data from a table that stores Java UUIDs as binary(16)
.
For example, the UUID 76572de1-aa8c-435b-afe4-8e260e19466b
looks like this in phpMyAdmin: 0x76572de1aa8c435bafe48e260e19466b
.
Now, how can I query any values from that table by using a simple string?:
SELECT ... WHERE uuid = '76572de1-aa8c-435b-afe4-8e260e19466b'
SELECT ... WHERE uuid = '76572de1aa8c435bafe48e260e19466b'
SELECT ... WHERE uuid = '0x76572de1-aa8c-435b-afe4-8e260e19466b'
SELECT ... WHERE BINARY uuid = '76572de1aa8c435bafe48e260e19466b'
SELECT ... WHERE BINARY uuid = '76572de1-aa8c-435b-afe4-8e260e19466b'
- and a lot of other things utilizing
CONVERT
orBINARY
keywords
2
Answers
Hexadecimal literals in MySQL look like this:
X'01AF'
or this:0x01AF
(case insensitive in both cases.One option would be
SELECT ... WHERE uuid = X'76572de1aa8c435bafe48e260e19466b'
Use BIN_TO_UUID() and UUID_TO_BIN() functions.