mysql - Why select CAST(b'11' AS DEC); equals 3? -


mysql> select cast(b'11' dec); +--------------------+ | cast(b'11' dec) | +--------------------+ |                  3 | +--------------------+ 1 row in set (0.00 sec) 

but:

mysql> select cast(a'11' dec); error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near ''11' dec)' @ line 1 

why? it's strange. thanks.


it seems question isn't clear enough. make apology here. b'11' doesn't equal a'11'. , there absolutely kind of type cast there. , question is, why b'11' equal 3 in binary notation, after typecasting. b'11' doesn't binary number.

b'11' 11 in binary notation, it's 3 in standard, decimal one.


Comments