How to find certain Hex values and Char() Values i

2019-03-01 12:54发布

问题:

Anyone know the syntax to search a MySQL table column by hex value or CHAR() value? Do I have to use a LIKE or IN()?

Something like:

SELECT * FROM `myWordTable` WHERE `definition` LIKE 0xE28098;

OR

SELECT * FROM `myWordTable` WHERE `definition` LIKE CHAR(128);

Thanks!

回答1:

The second one is close.

Try this:

SELECT * 
FROM `myWordTable` 
WHERE `definition` 
LIKE concat('%',CHAR(128),'%');


回答2:

In the first example consider pattern match '%' == 0x25

SELECT * 
FROM `myWordTable` 
WHERE `definition` 
LIKE 0x25E2809825;


回答3:

You need to UNHEX() values you want to match on.

For example, finding all accented e's that were corrupted into 0xC3A9:

SELECT id, FirstName
FROM Person
WHERE FirstName
RLIKE UNHEX('c3a9');


标签: mysql sql char hex