Multiple field search form

Results 1 to 2 of 2

Thread: Multiple field search form

  1. #1
    Join Date
    Dec 1969

    Default Multiple field search form

    can anyone point me to a tutorial or article that will help me to create the results page for a 3 form search query. I can create a SQL call just fine when only one keyword field is used, however, this poses alot more concerns.<BR><BR>This will be an "Advanced Search" form in which the user can enter into any of three fields: 1. Keyword or phrase 2. City and 3. Zip code<BR><BR>THX in advance.

  2. #2
    Join Date
    Dec 1969

    Default RE: Multiple field search form

    There&#039s nothing magical or tough about it.<BR><BR>Let&#039s say that before you did something like<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;SQL = "SELECT * FROM table WHERE field1=" & Request("field1")<BR><BR>or maybe<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;SQL = "SELECT * FROM table WHERE field1=&#039" & Request("field1") & "&#039"<BR><BR>if the DB field is a string (VARCHAR, TEXT, whatever) or maybe<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;SQL = "SELECT * FROM table WHERE field1=#" & Request("field1") & "#"<BR><BR>if the DB field is a date *and* you are using Access (non-Access DB&#039s treat dates same as strings).<BR><BR>So now, to use more than one field, you just tack on an AND clause to the WHERE:<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;SQL = "SELECT * FROM table" _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;& " WHERE field1=" & Request("field1") _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;& " AND field2=" & Request("field2") _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;& " AND field3=" & Request("field3")<BR><BR>Naturally, in each case, if the DB field is a string or date, instead of a number, you have to surround it with &#039...&#039 or #...# just as you do for a single field.<BR><BR>Your code can use AND, OR, AND NOT, etc., etc. All the stuff you&#039d expect in a logical expression.<BR><BR>For a nice one-html-page summary of the capabilities of SQL, see here:<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;<BR><BR>

Posting Permissions

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