B
B
Barnie Savington2018-03-06 05:11:59
MySQL
Barnie Savington, 2018-03-06 05:11:59

How to convert VARCHAR to numeric HEX?

There is a table with a hash VARCHAR column.
I want to make the following query work:

SELECT *, hash ^ 0x614700980404999e as h from images;

How to specify (convert) here that hash is a hexadecimal number?
Let's say we have a table
id | hash
1 | 39322f4c431a5eef
2 | 614700980404999e

Direct use: SELECT 0x39322f4c431a5eef ^ 0x614700980404999e;
Gives us 6374053436385576817, as expected,
But if we use a selection, we get
id | hash | h
1 | 614700980404999e | 7009060661561924249
2 | 39322f4c431a5eef | 7009571997927866372

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Tsvetkov, 2018-03-06
@iwex

SELECT *, CONV(hash,16,10) ^ 0x614700980404999e as h from images;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question