Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Partial Matches

Status
Not open for further replies.

DarkMan

Programmer
Apr 13, 1998
222
US
I would like to be able to detect partial matches in a Database field. I know the LIKE command, but it doesn't seem to want to work here. What I'm trying to match has the wildcard character IN the database field, the reverse of the usual where %xxx% = FIELD. The fields are layed out similar to this h%dh%nt%r.
 
There are a couple of ways you might try. Remember that the '%' is used for multiple character wildcards. You can also use a single character search, I believe its the '?' but I would have to look it up. The search that you are using should work, but if your fields are long, then you will have problems. There is no wildcard that will do UP TO (say) 5 characters, but not more. If you want more than one character, you statement building it from scratch would grow exponentially, and I think it would cause you other problems.



It does look like you are searching for key words, or full text indexing. Are either of these the case?



There are some other ways of thinking about how to do things. If you want to give me some more info, I will try to help out.



I hope this was useful.
 
Here's my code: SELECT Handle.Mail, Restrict.Email from Handle, Restricted WHERE Handle.Mail LIKE Restrict.Email. My wildcard characters are in Restrict.Email. It gives me an error saying that I am improperly using the field (like it is in the wrong place). If I put Restrict.Email first, it doesn't return anything at all, even when I know it should give me a match.
 
Salam (Hi)<br>
There are two wild cards that are used in SQL, LIKE and Underscore '_' and you can use these as<br>
<br>
Example 1<br>
Select Field1 from mytable where Field1 LIKE '%mile'<br>
Result: It will retrieve words that start with anything but that end with mile. e.g Smile, Shumile, frafrommile etc.<br>
Example 2<br>
Select Field1 from mytable where Field1 LIKE 'mi_e'<br>
Result: It will return words that start with 'm' end with 'e' but can contain any character after 'i' e.g "mine", "mile", "mike" etc.<br>
This '_' is called character wild card.<br>
<br>
I hope it will help you. :)
 
Thanks, actually that was exactly what I was looking for. I'll give it a try...:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top