MySQL equivalent MSSQL CONVERT ()

I have this MSSQL fragment -

CONVERT(INT, HASHBYTES('MD5', {some_field}))

... and I would really like the MySQL equivalent. I'm sure the bit is the HASHBYTES('MD5', ...)same as MySQL MD5(...)- this is the bit CONVERT(INT, ...)that really puzzles me.

Thank.

+5
source share
1 answer

From the MySQL user guide for the function MD5():

The value is returned as a string of 32 hexadecimal digits or NULL, if there was an argument NULL.

The MSSQL function CONVERT()that you quote above converts its argument varbinaryto a 32-bit integer, truncating to the least significant 4 bytes. This is a bit unpleasant because MySQL arithmetic works with 64-bit precision.

8- MySQL- ( 4 ) MySQL CONV(), sign-extend :

CONV(RIGHT(MD5('foo'),8), 16, 10) ^ 0x80000000 - 0x80000000
+6

All Articles