MonoThreaded
MonoThreaded

Reputation: 12033

How I can I SELECT rows based on string containing ascii code 0x02?

I would like to locate all strings in a table containing the 0x02 character.
For clarity, I am looking for something like:

SELECT * FROM table WHERE column LIKE '%0x02%'

Upvotes: 3

Views: 1527

Answers (2)

David Gorsline
David Gorsline

Reputation: 5003

I would go with

SELECT * FROM table WHERE LOCATE(X'02', column) > 0

Upvotes: 3

Cylindric
Cylindric

Reputation: 5894

Hex literals? A % is 0x25

SELECT * FROM table WHERE column LIKE 0x250225

Checking the manual reminds me that the 0x syntax isn't strictly SQL standard, so maybe use X'' instead

SELECT * FROM table WHERE column LIKE X'250225'

Upvotes: 2

Related Questions