Creating a SQL query based on a Multiple Select li

Results 1 to 2 of 2

Thread: Creating a SQL query based on a Multiple Select li

  1. #1
    Join Date
    Dec 1969

    Default Creating a SQL query based on a Multiple Select li

    I&#039;m kind of stuck and I&#039;m also on a pretty tight deadline schedule which doesn&#039;t make for the best of situations.<BR><BR>Here&#039;s a quick synopsis of my problem. I&#039;ve got a form where the user can search for land based on a multi-select list box which contains several hundred zipcodes (among other options). The user can choose as many zips as they want, and then the query returns results in any of the selected zips.<BR><BR>I&#039;ve got the form working ok, and I &#039;THINK&#039; I&#039;ve been able to put the returned list of zipcodes into a usable format based on the code I wrote below.<BR><BR>(The code first checks to see if specific zips were selected, otherwise it searches ALL of them)<BR><BR>--------<BR><BR> if UBound(sZipCode) &#062;= 0 then<BR> sLinkStr = sLinkStr & "&zip="<BR> i = 0<BR> do while i &#060;= UBound(sZipCode)<BR> strZipCode = strZipCode & server.URLEncode(Trim(sZipCode(i))) & ","<BR> i = i + 1<BR> loop<BR> strZipCode = Left(strZipCode, Len(strZipCode)-1)<BR> sLinkStr = sLinkStr & strZipCode<BR> end if<BR> <BR>--------<BR><BR>I just need a very simple way of creating a "WHERE" statement on the results page that will account for this type of array. I&#039;m not a SQL person and I&#039;m kind of stuck. Thanks in advance!<BR><BR>- Adam

  2. #2
    Join Date
    Dec 1969

    Default RE: Creating a SQL query based on a Multiple Selec

    Why do you do all of that?<BR><BR>If you simply do Request.Form("ZipCode"), you get a comma+space delimited list of selections.<BR><BR>And, to use that in a SQL statement, look into the IN() clause.

Posting Permissions

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