PDA

View Full Version : Query comes up empty but...


GenVic
08-04-2009, 05:16 PM
clearly the column has the data I'm looking for. Even using the broad "LIKE" command I get nothing yet when I visually scroll down to the rows in phpmyadmin I see a total of 13 rows with the word I'm looking for in the data.

What could be causing this? btw, the query does work for some phrases and not others.

djm0219
08-04-2009, 05:42 PM
Show us what you've tried and what your data looks like. We can't possibly begin to guess what might be causing something without seeing what you have.

GenVic
08-04-2009, 06:30 PM
SELECT * FROM `products` WHERE `brand` LIKE 'nike'
SELECT * FROM `products` WHERE `brand` = 'nike'

This returns 1 result

Yet when I click at the top of the column to sort by ascending or descending I can clearly see 5 "nike" in the brand column.


Hope this helps, initally I thought maybe it had something to do with the collation, since it was different (spanish)

ckeyrouz
08-04-2009, 06:36 PM
You have two reasons for not returning data:

Case sensitive issue (capital letters and small letters)
Match whole word issue (you might nike shoes for example)


try this query:
SELECT * FROM `products` WHERE lower(`brand`) LIKE '%nike%'

GenVic
08-04-2009, 08:13 PM
You have two reasons for not returning data:

Case sensitive issue (capital letters and small letters)
Match whole word issue (you might nike shoes for example)


try this query:
SELECT * FROM `products` WHERE lower(`brand`) LIKE '%nike%'

That did it man, in my case I changed it to upper. Thanks for the help.

ckeyrouz
08-04-2009, 08:16 PM
If my post helped you can you please click on the button thank user since I am trying to increase my credits on this forum.

It's not a big deal if you do not want to do it.

In both cases thank you.