Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / March 2007



Tip: Looking for answers? Try searching our database.

Help With Field Searching Using Wildcards

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy - 27 Mar 2007 19:25 GMT
Hi Gang

I have a small database application where the user can search
different fields.  They select what they want to search on and enter a
value to search on.  For example

They select part number and enter "123" into the search field.

This searches the database for that field with LIKE '%123%'.

What I want the user to be able to do is add wildcards to the search.
For example

They select the part description field and enter "Dohicky*123" or
"Dohicky?123"

I want the search to process the wildcards as you would expect.  What
is the easiest way to do this?

Regards,
Andy
Bob Barrows [MVP] - 27 Mar 2007 19:38 GMT
> Hi Gang
>
[quoted text clipped - 14 lines]
> I want the search to process the wildcards as you would expect.  What
> is the easiest way to do this?

The same way. Only have your users use the ODBC wildcards (% and _) not
the Jet wildcards
Signature

Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Andy - 27 Mar 2007 19:42 GMT
Hi Bob

Just to confirm... % is equal to * and _ is equal to ?

Is that right?

Regards,
Andy
Bob Barrows [MVP] - 27 Mar 2007 20:00 GMT
> Hi Bob
>
> Just to confirm... % is equal to * and _ is equal to ?
>
> Is that right?

Yes.
You could allow the user to enter the jet wildcards and simply replace
them with the ODBC wildcards before putting the string into the query
... but then you get into all the "escaping" issues, which I'm sure you
haven't thought through: what if the user wants to search for a string
containing those literal characters?
Signature

Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Andy - 27 Mar 2007 20:06 GMT
Thanks Bob

That's exactly what I needed to know.  Right now we'll just add the *
as that's all our users want.  Our data shouldn't have a * in it.

Regards,
Andy
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.