MySQL LIKE '%...%' query won't work -
tMike - 06.06.2012
Hi there,
i've work on it a long time and it will not work (I use StrickenKids MySQL Plugin).
I tested these query
Код:
SELECT * FROM `help` WHERE `searchWord1` LIKE '%%s%' LIMIT 0 , 30
For example i type in "hous", it should look like this
Код:
SELECT * FROM `help` WHERE `searchWord1` LIKE '%hous%' LIMIT 0 , 30
I tested a lot of methods, for example this one:
Код:
SELECT * FROM `help` WHERE `searchWord1` LIKE '% %s %' LIMIT 0 , 30
This will printed in this form: "% hous %", but the mysql-database don't know what to do with it.
I have saved "house" in searchWord1, i want to make a search system on my server.
The database should also find the content when I use the name of the column specified imprecise.
When i type in "hous" as a search-word it should find the content with "house" (with the sql field in phpmyadmin it works perfectly, but not with mysql_query, - maybe it lay on the strings?).
I've printed it and this will come out:
Код:
SELECT * FROM `help` WHERE `searchWord1` LIKE '%s' LIMIT 0 , 30
(only the percent and the S, not the string which i have defined!)
Thanks for help, sorry for my bad english.
Re: MySQL LIKE '%...%' query won't work -
Calgon - 06.06.2012
Try using a double percentage sign. If you're using format(), you need to escape the percentage sign properly or it'll cause problems.
A single percentage sign in format() is considered as a placeholder, more than 1 will actually show in the string properly.
Код:
SELECT * FROM `help` WHERE `searchWord1` LIKE '%%%s%%' LIMIT 0 , 30
AW: MySQL LIKE '%...%' query won't work -
tMike - 06.06.2012
Thanks a lot, genius.