Search a Database on Partial String Matches

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*’.

See also  Comparing different methods of testing your Infrastructure-as-Code

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist