CREATE TABLE `tmp` (
`wid` bigint unsigned NOT NULL,
`simhash` binary(255) NOT NULL,
PRIMARY KEY (`wid`),
UNIQUE KEY `u_simhash` (`simhash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
TRUNCATE `tmp`;
insert into tmp set wid=4, simhash=b'10';
SELECT wid,bin(simhash+0) FROM tmp;
As above, I want to insert a binary string '10' (equals to decimal 2) to a binary field.
But it fails. the result of bin(simhash+0) is 0, not 10 as I expected.
So what is the problem? I just want to insert binary string (like '1000110101101....') to the binary field.
- Env: MySQL 8.0.40
- Client: MySQL Workbench 8.0.40
PS: Use SELECT bin(simhash+0) to get the binary string of the field. E.g. display '10' for the decimal number 2.

Truncated incorrect DOUBLE value: '\x02\x00\x00...').BIN()function in yourSELECTstatement. The column is already "binary".