Dima Dz
Dima Dz

Reputation: 538

Mysql, querying varchar column with like gives no result

In Mysql database, I have a table. Columns are id (int), name (varchar 40). The name column has a couple of cells with just 'NO' strings stored.

Why do I get nothing in return if I query something like below?

select * 
from TABLE_NAME 
where name like '%NO%'

or

select * 
from TABLE_NAME 
where name = 'NO'

Any help for the drowning?

Upvotes: 2

Views: 80

Answers (2)

Juan Carlos Oropeza
Juan Carlos Oropeza

Reputation: 48177

You can do something like this

select 
     SUBSTRING(name, 1,1) AS value1,
     SUBSTRING(name, 2,1) AS value2,
     SUBSTRING(name, 3,1) AS value3,
     SUBSTRING(name, 4,1) AS value4,
     SUBSTRING(name, 5,1) AS value5,
     ASCII(SUBSTRING(name, 6,1)) AS value6
from TABLE_NAME

Then use ascII function to see each character value.

Upvotes: 4

Rohit Gupta
Rohit Gupta

Reputation: 4191

You obviously have some character between N and O. Using '%n%' search or something similar, I would update them to 'NO' .

Upvotes: 2

Related Questions