creating a wildcard search for a database

Results 1 to 2 of 2

Thread: creating a wildcard search for a database

  1. #1
    Join Date
    Dec 1969

    Default creating a wildcard search for a database

    I&#039;m currently working on my first database driven site, and I&#039;m setting up simple search function. I&#039;m using Ultradev and Access. I have set up a search page and am accessing database and getting my results ok. However I want to set it up so a less defined search can bring results, for example: <BR><BR>If i&#039;m looking for "Shakespeare" I will have to enter "Shakespeare, William" as the database has "Shakespeare" William&#039; as an entry. I want to make so if a user types "Shakespeer" they will find the "Shakespeare, William" database entry. <BR><BR>I have noticed that if "Shak*" is to be used the entry will be found. I have thought that if I could take the first 4 letters of the search field add a wildcard to it and pass it as a variable to the recordset it could then accomodate for less-defined search querys made by users.<BR><BR>IS THIS THE BEST WAY TO DO THIS???<BR><BR>I&#039;m kinda new to this and my .asp knowledge is small but increasing. Sorry if this is dum and simple.<BR><BR>Help us out if u can, cheers,<BR><BR>DAN

  2. #2
    Join Date
    Dec 1969

    Default Use LIKE

    sSQL = "SELECT Fields FROM Table WHERE Field LIKE &#039;%" & UserSearchTerm & "%&#039;"<BR><BR>This will find the value of the UserSearchTerm (which you will presumably populate from a Form collection) ANYWHERE in the field.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts