Ask the Expert

How do I create a wildcard search in my database program?

I'm building a SQL database program to search for names or numbers. I know how to get the exact name or number. But I would like to use a wildcard to show everything starting with "the first few letters" or "the first few numbers." I'm using OleDBDataAdapter to access my database. (VB.NET)
Use SQL "LIKE" keyword together with the "%" wildcard. For example: SELECT * FROM authors WHERE fname LIKE 'J%' (will give you John and Jason) SELECT * FROM authors WHERE telephone LIKE '54%' (will give you all lucky authors living in Argentina -- such as myself!)

This was first published in June 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: