Forums

ASP

This topic is locked

Some help pls....

Posted 03 Apr 2010 07:41:57
1
has voted
03 Apr 2010 07:41:57 metin yaman posted:
I'm gonna ask for some help ...My question is very simple ...
i have codes like "abc 4515" or "abc 6525/2" in my access database .(pls note that there is "space" between the whole code ...)So all i wanna do is to find these details in my search result page BUT even if i write in search form "abc4515" or "a b c 4 5 1 5" i still want to find the codes or the code which is the closest one to the search ....?Pls at leats give me some idea about it ....If you can tell me what do i have to do or how do i have to do it (do i have to use function or something) i will appreciate it ...

Thanks in advance

Kind Regards
Metin

Replies

Replied 04 Apr 2010 21:27:01
04 Apr 2010 21:27:01 metin yaman replied:
Any idea ....? []
Replied 05 Apr 2010 15:42:51
05 Apr 2010 15:42:51 Javier Castro replied:
your SQL query should be something like:

SELECT * FROM myDB WHERE yourfield LIKE "Param%"

The above looks for anything that starts with a and whatever the rest of the word is. If the percentage sign is in from then the first work could be anything and the rest would be an approximation to the word your are searching for.

Hope it helps.
Replied 06 Apr 2010 12:06:07
06 Apr 2010 12:06:07 Patrick Woldberg replied:
When you're codes always have 3 characters and then some numbers you could try:

param = Replace(Request("Search"), " ", "")
If Len(param) > 3 Then
  param = Left(param, 3) & " " & Mid(param, 3)
End If
sql = "SELECT * FROM Table WHERE Code LIKE '" & Replace(param, "'", "''") & "%'"


You should probably do some more checking (using regexp) and I would suggest using ADODB.Command with parameters to protect yourself for sql injections.

Reply to this topic