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