28 March 2012

mysql hex

mysql> SELECT X'4D7953514C';
      -> 'MySQL'
mysql> SELECT 0x0a+0;
      -> 10
mysql> SELECT 0x5061756c;
      -> 'Paul'

 default type ada string. kalau nak paksa sebagai nombor, guna CAST(.... AS UNSIGNED)
mysql> SELECT 0x41, CAST(0x41 AS UNSIGNED);
      -> 'A', 65

 ........................
tambahan:
mysql> SELECT HEX('cat');
      -> '636174'
mysql> SELECT 0x636174;
      -> 'cat'

 ref>> http://dev.mysql.com/doc/refman/5.0/en/hexadecimal-literals.html

No comments:

Post a Comment

Terima kasih