What really is the difference between MySQL UNHEX and X when dealing with hexadecimal values in a database?
Eg.
SELECT * FROM test WHERE guidCol IN (UNHEX('hexadecimalstring'));
SELECT * FROM test WHERE guidCol IN (X'hexadecimalstring');
Both gives me exact result set. So is there any difference? Performance implications?
Edit: the underlying type of guidCol is binary of course
UNHEX()is a function, therefore you can do something likeX, on the other hand, is the syntax for a hexadecimal litteral. You cannot do this:This explains why you always get better performance with
X: you are using a language construct instead of a function call.Xdoes not need to evaluate a variable, since it expects a litteral string.