Any idea of why this is so,
CREATE TABLE f AS
SELECT b'000000001' AS a, x'01' AS b;
This creates two columns of
`a` varbinary(2) NOT NULL,
`b` varbinary(1) NOT NULL
However, when I run,
SELECT a=0, b=0, a=b, a<>b FROM f;
+-----+-----+-----+------+
| a=0 | b=0 | a=b | a<>b |
+-----+-----+-----+------+
| 1 | 1 | 0 | 1 |
+-----+-----+-----+------+
What's going on here? From the docs on The BINARY and VARBINARY Types,
All bytes are significant in comparisons, including
ORDER BYandDISTINCToperations.0x00bytes and spaces are different in comparisons, with0x00 < space.
That explains why a<>b, but why does a=0, or b=0 there?