Search a Database on Partial String Matches

I have a database hooked up to my Web page. I can do a search and it works fine, but during my search, if I spell a word wrong, it will not return anything. How do I make it possible to search on a part of the input? For example, I want to be able to type (zz) and not (zz top) and get all the fields that have zz in them.


In your SQL Statement where you are doing the search, instead of saying:

WHERE [field] = 'value'

Try saying:

WHERE [field] = '%value%'

This code is valid for SQL Server. If you are using Access, you need to use ‘*value*’.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: