Answer the question
In order to leave comments, you need to log in
How to make MySql consider the text value of a HEX column as a number?
The essence of the task: it is necessary to compare two HEX values bit by bit, one comes from php, the second lies in the database in text form. The problem is that it is not possible to pull out the second value as a HEX number, only as a string. The first number is "pasted" into the request on the php side like this "SELECT hash ^ 0x".$hash." FROM...." and there are no problems with this.
How to make MySql consider the text value of a HEX column as a number?
For example, if you make a query with your hands and enter 2 hex there SELECT 0xd9d8266fd990160f ^ 0xd9d8266fd990160e
, then it will return 1, as expected
. SELECT 0xd9d8266fd990160f ^ column from table
That returns nonsense, because considers the value of the column not HEX, but string.
Answer the question
In order to leave comments, you need to log in
If the hash column contains the string 'd9d8266fd990160f', then try this query:
SELECT CONV(hash, 16, 10) ^ 0xd9d8266fd990160e FROM table
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question