I have a column with type binary(16) not null
in a mysql table. Not all records have data in this column, but because it setup to disallow NULL
such records have an all-zero value.
I want to exclude these all-zero records from a query.
So far, the only solution I can find is to HEX
the value and compare that:
SELECT uuid
FROM example
WHERE HEX(uuid) != '00000000000000000000000000000000'
which works, but is there a better way?
select uuid from example where uuid is not null
? – Selfabasementbinary
columns are always padded with\0
. So inserting an empty string''
gives N times\0
. I think that's the problem here. Nice riddle, though. Let's wait for Gordon... ;-) – Asch