Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert binary string to bigint in MySQL?

I am attempting to hash a string to a 64-bit value (bigint) in MySQL. I am aware of the MD5() function, which returns a 128-bit hash as a binary string. I'd be happy to just take the bottom or top 64 bits of this result. However, I cannot figure out how to get from a binary string type to a numeric type of any sort. Any pointers?

like image 628
Sean Owen Avatar asked Aug 11 '09 10:08

Sean Owen


1 Answers

You could also use CRC32 function that returns 32-bit unsigned value.

SELECT CRC32(id) from SomeTable;

Documentation

like image 79
Łukasz Żarczyński Avatar answered Oct 25 '22 12:10

Łukasz Żarczyński