According to many php sites, the code below should return anything containing the $search_id:

keyword like '%$search_id%'

But if I do a search on red cars (plural) then 0 results are given
if I do a search on red car then 122 results are given.

Why is the % sign not working for the red cars $search_id?

    Probably because there is nothing in the database that includes the string "red cars". The "%" wildcards mean any number of any characters at that point, but they have no effect on the literal characters you have between them. ("LIKE" does not do some sort of intelligent, "fuzzy" search; it just allows you to use those wildcard characters so that you can search for a partial match within the value. If you need to do such a "fuzzy" search, you may want to look into MySQL's FULLTEXT search capabilities -- assuming you are using MySQL.)

      I'm using MySql, true, will have a look into Fulltext search as the descriptions aren't that long.

      cheers mate!

        Write a Reply...