Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
Aug 12, 1999

Search a Database on Partial String Matches

Question:
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.

Answer:

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

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date