Can there any way to insert a hex value into MYSQL? I also want to be able to retreive it in hex form.
For example, something like: INSERT INTO table ( hexTag ) VALUES ( HEX(0x41) );
And if I do this, I want it to put an 'A' into the table
Can there any way to insert a hex value into MYSQL? I also want to be able to retreive it in hex form.
For example, something like: INSERT INTO table ( hexTag ) VALUES ( HEX(0x41) );
And if I do this, I want it to put an 'A' into the table
For that particular use case, you can either insert the hex value directly and it will be interpreted as a string, or use HEX() to input and UNHEX() to output
mysql> create table hexTable(pseudoHex varchar(50)); Query OK, 0 rows affected (0.01 sec) mysql> insert into hexTable values (0x41); Query OK, 1 row affected (0.00 sec) mysql> select * from hexTable; +-----------+ | pseudoHex | +-----------+ | A | +-----------+ 1 row in set (0.00 sec) mysql> select HEX(pseudoHex) from hexTable; +----------------+ | HEX(pseudoHex) | +----------------+ | 41 | +----------------+ 1 row in set (0.00 sec) mysql> delete from hexTable; Query OK, 1 row affected (0.00 sec) mysql> insert into hexTable values (HEX('A')); Query OK, 1 row affected (0.00 sec) mysql> select UNHEX(pseudoHex) from hexTable; +------------------+ | UNHEX(pseudoHex) | +------------------+ | A | +------------------+ 1 row in set (0.00 sec) mysql> select * from hexTable; +-----------+ | pseudoHex | +-----------+ | 41 | +-----------+ 1 row in set (0.00 sec)