vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hey, I have a table with a SMALLINT column that -- trough a mistake -- contains values like 57, 13 etc. which in fact are 0x57 and 0x13 (i.e. HEX numbers). How would I convert 13 ("false decimal") to 0x13 (Hex) and from there to 19 (decimal)? I tried my luck with UNHEX and CAST but I only got 0 or NULL back respectively. Thanks in advance Fred |
| |||
| > I have a table with a SMALLINT column that -- trough a mistake -- > contains values like 57, 13 etc. which in fact are 0x57 and 0x13 (i.e. > HEX numbers). > > How would I convert > > 13 ("false decimal") to 0x13 (Hex) and from there to 19 (decimal)? > > I tried my luck with UNHEX and CAST but I only got 0 or NULL back respectively. This seems to work: select cast(x'13' as unsigned) So treat the column as a string (or cast it like that) and use this cast. Martijn Tonies Database Workbench - development tool for MySQL, and more! Upscene Productions http://www.upscene.com My thoughts: http://blog.upscene.com/martijn/ Database development questions? Check the forum! http://www.databasedevelopmentforum.com |
| |||
| Frederic Wenzel napsal(a): > Hey, > > I have a table with a SMALLINT column that -- trough a mistake -- > contains values like 57, 13 etc. which in fact are 0x57 and 0x13 (i.e. > HEX numbers). > > How would I convert > > 13 ("false decimal") to 0x13 (Hex) and from there to 19 (decimal)? > > I tried my luck with UNHEX and CAST but I only got 0 or NULL back > respectively. > > > Thanks in advance > Fred > conv('column_name', 16, 10) Dusan |