varbinary - Working with Binary Data in MySQL -


select        0x0000987c col1,       substr(binarydata,1,4) col2,       cast(0x0000987c  signed) col3,       cast(substr(binarydata,1,4)  signed) col4 ( select 0x0000987c00000000 binarydata ) d 

returns

col1  col2   col3  col4 ----  ----  -----  ---- blob  blob  39036   0 

when @ blob viewer col1 , col2 both appear identical (screenshot below).

so why different results col3 , col4?

screenshot

i think has data types. binarydata has integer data type, substr(binarydata,1,4) expects string. cast gets confused result. also, cast parses strings using base 10, need little bit of work. try this:

cast(conv(substr(hex(binarydata),1,8), 16, 10)  signed) col4 

it's monster, should give want.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -