Why SQL LIKE not working here?

I have this in database:

new - Jardim das Palmeiras, Franca - SP, 14406-706, Brazil

Now I use: WHERE row LIKE '%new jardim das palmeiras%'

But it’s not matching why?

because your strings do not match

new jardim das palmeiras
new - Jardim das Palmeiras

notice the dash which is absent in the search pattern

if you want to search for a pattern like this you will need fulltext search instead of like

1 Like

My script takes this data from URL: new-jardim-das-palmeiras

so what?

It doesn’t match!

Yes, it doesn’t

1 Like

do you know a way around it?

Yes, and I told you it already. You have to use fulltext search instead of like.

Buddy thanks could you please help me out with the cod I am kind of a newbie!

Ok, here is your issue, which @colshrapnel has pointed out, but I’m gonna try to rephrase it for you. In order for SQL to match the strings, even with LIKE, the stuff between the percents must match somewhere on the string. In the row you want to find, the query you are running does not match because there is a dash (-) between new and Jardim, where as in your SQL statement, there is no dash. Try removing the new and the space so your query looks like this
WHERE row LIKE '%jardim das palmeiras%
and it will match the row you have supplied.

EDIT: Honestly looking at the thread a second time, I couldn’t really tell if this was resolved before I got here or what. So I’m just gonna leave this here.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.