i'm converting table has column storing integers hexadecimal strings. i'd convert these strings integers, take less space , easier query. however, seems mysql lacks efficient way convert binary int.
this works:
select cast(conv(some_column, 16, -10) signed); -- some_column = "49858170ef9a4f63" ...but converts decimal string first, less ideal. i'd convert directly integer, bypassing string:
select convert(unhex(some_column), signed); -- some_column = "49858170ef9a4f63" ...but doesn't work; 0. seems doing same thing cast.
how can convert binary value directly int, without first converting string? in more abstract sense, how can change type of value without changing underlying data?
note purely mysql; not using php or other scripting language.
short of creating own stored function, don't think there way can avoid converting string first.
i guessing unhex not working because (at least mysql's official example suggests), hex/unhex convert string/decimal bytes to/from hex characters representation, , hex strings of '0x???' format, convert change '0'.
given conv has parse string anyway, doubt converting decimal string requires additional overhead.
Comments
Post a Comment