CJS
CJS

Reputation: 1545

How to query MySQL for fields containing null characters

I have a MySQL table with a text column. Some rows have null characters (0x00) as part of this text column (along with other characters).

I am looking for a query that will return all rows containing any null characters for this column, but I cannot figure out how the proper syntax for my "where column like '%...%'" clause.

Thank you!

Upvotes: 14

Views: 6036

Answers (2)

CJS
CJS

Reputation: 1545

Right after I submitted the question, a suggested link to this related question provided my answer: Query MySQL with unicode char code

WHERE CAST(column AS BINARY) LIKE CONCAT("%", 0x00, "%")

Upvotes: 16

Drew
Drew

Reputation: 1440

The following worked for me...

WHERE column LIKE "%\0%";

Upvotes: 3

Related Questions