Query with like and or_like not returning like results |
[eluser]Zac G.[/eluser]
Hi folks, I am working with this method: Code: $this->db->like('first_name', $keywords); If I type in a name exactly how it appears in the database it returns the results, however, if I type a name in that is not exactly how it is written it returns does not usually return any results. Am I making a mistake with somewhere with the code, or am I just not understanding the limitations of of MySQL like? For example, Name in database: "Sarah" I type "Sara" and get a result. Another name in database: "Zac" and type "Zak" I get nothing. Am I doing something wrong wrong, or is there a way that I can strengthen the power of the like search? Thanks! Zac
[eluser]blasto333[/eluser]
That is not how LIKE matches. It will look for (any characters)Zac(any characters) You might want to look into Full Text searching. (http://dev.mysql.com/doc/refman/5.0/en/f...earch.html) (I haven't tried this, but maybe others will have better suggestions)
[eluser]Zac G.[/eluser]
Ah, thanks blasto333. I had thought that LIKE runs a function to get queries that "sound" like that word. Thanks!
[eluser]CrustyDOD[/eluser]
Use % before/after the search term. For example: Code: SELECT ... LIKE 'Sara%' If you have huge DB i would recommend full-text searches as LIKE is really slow..
[eluser]Zac G.[/eluser]
So it turns out what I was looking for was SOUNDS LIKE. Does anyone have a good sounds like search module that they use? Cheers! |
Welcome Guest, Not a member yet? Register Sign In |