Advanced Select Query

A

Aaron

I need a query that can return wildcard matches if there's no exact
match. There's how the process works.

1. Input = "my email address is (e-mail address removed)"
2. Look for exact match.
3. Look for wildcard match.
4. Found = "my * address *"
5. output = "my * address *"

I hope this makes sense,
Thanks in advance
Aaron
 
J

Joey Powell

Aaron, use a SqlDataReader or an OleDbDataReader to query your
database for an exact match - at first use "SELECT [FieldName] FROM
[TableName] WHERE [FieldName]='[SearchCriteria]'".

The results from the .ExecuteReader method will return the total
number of rows affected by the query. If that equals zero (which would
indicate no exact match) then modify the select statement to include
the SQL LIKE keyword and then execute the reader again - "SELECT
[FieldName] FROM [TableName] WHERE [FieldName] LIKE
'[SearchCriteria]'". If it still returns zero then no match would
exist, period.

This process would return and exact or approximate match. HTH JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top