I am newbie in MySQL and I am quite confused en how to insert and after how to retrieve row using this hash in where clause in a varbinary type column.
/*sql*/
CREATE TABLE my_table(hash_column VARBINARY(32));
//php
$hash = "3cd63ba0e52e7c16316bd3b1d33a1bdbc6128fa55f4747c80ac4eab104a9f459";
//this seem to work ok because I can see new item in my_tabl
$sql = "INSERT INTO my_table (hash_column) VALUES ('$hash');
//there is my problem y have tried all this but got 0 result
$sql = "SELECT * FROM my_table WHERE hash_column = '$hash'";
$sql = "SELECT * FROM my_table WHERE hash_column = HEX('$hash')";
$sql = "SELECT * FROM my_table WHERE hash_column = BINARY HEX('$hash')";
$sql = "SELECT * FROM my_table WHERE hash_column = BINARY '$hash'";
SOLVED: With some ideas from @JuveLeo1906 and @Psi and this post What data type to use for hashed password field and what length? that help me find the right solution.
Right solution here:
$sql = "INSERT INTO my_table (hash_column) VALUES (UNHEX('$hash'));
$sql = "SELECT * FROM my_table WHERE hash_column = UNHEX('$hash')";