User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 429,817 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,383 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting

Using REGEXP in searching

Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Using REGEXP in searching

  #33  
Mar 6th, 2008
whatinput = "Coldstreet 123A 12345 Freezytown"


array = whatinput.split(" ")


SQL = "SELECT CL.organisation, CA.street,CA.zipcode,CA.city,RG.state,RG.stateID,KO.county,KO.countyID "&_
"FROM tbclientaddress CA "&_
"JOIN tbclients CL ON CA.clientlink = CL.clientID "&_
"JOIN tbstate RG ON CA.state = RG.stateID "&_
"JOIN tbcounty KO ON CA.county = KO.countyID "&_
"WHERE "

For numero = 0 To UBounds(array)
  Select Case numero
    Case 0
      SQL = SQL & " CA.street LIKE '%" & array(numero) & "%' "
    Case 1
      SQL = SQL & " OR CA.streetnumber LIKE '%" & array(numero) & "%'"
    Case 2
      SQL = SQL & " OR CA.zipcode LIKE '%" & array(numero) & "%'"
    Case 3
      SQL = SQL & " OR CA.city LIKE '%" & array(numero) & "%'"
    Case > 3
      SQL = SQL & " OR CA.city LIKE '%" & array(numero - 1) & "%" & array(numero) & "%' OR CA.city LIKE '%" array(numero) & "%'"
  End Select
Next

Set RS = Server.CreateObject("ADODB.recordset")
RS.Open SQL,Conn


Do While Not RS.EOF 

etc.. etc..

This is your SQL string for the following line:
"Coldstreet 123A 12345 Freezy Town"

SQL = ....
For ....
....
Next
....

'SQL Output String:
SQL = "SELECT CL.organisation, CA.street,CA.zipcode,CA.city,RG.state,RG.stateID,KO.county,KO.countyID "&_
"FROM tbclientaddress CA "&_
"JOIN tbclients CL ON CA.clientlink = CL.clientID "&_
"JOIN tbstate RG ON CA.state = RG.stateID "&_
"JOIN tbcounty KO ON CA.county = KO.countyID "&_
"WHERE CA.street LIKE '%Coldstreet%'"&_
" OR CA.streetnumber LIKE '%123A%'" &_
" OR CA.zipcode LIKE '%12345%'" &_
" OR CA.city LIKE '%Freezy%'" &_
" OR CA.city LIKE '%Freezy%Town%'"
" OR CA.city LIKE '%Town%'"
** Some changes have been made to my original post. Please copy this one.
Reply With Quote  
All times are GMT -4. The time now is 5:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC