I've tried that, as you can see from the code below. Say I wanted base my
search on BOTH the title AND author at the same time? How would I do that? I
keep getting the error "SQL Not Properly Ended, or something like that"
MD
String title = request.getParameter ("title");
String author = request.getParameter ("author");
String isbn = request.getParameter ("isbn");
String query = "SELECT Title, Author, ISBN, Cost, QuantityOnHand
FROM Products ";
if ( title != null && ! title.equals ("") )
query = query + "WHERE upper(Title) LIKE " + "upper('%" +
title + "%')";
if ( isbn != null && ! isbn.equals ("") )
query = query + "WHERE upper(ISBN) LIKE " + "upper('%" + isbn + "%')";
if ( author != null && ! author.equals ("") )
query = query + "WHERE upper(Author) LIKE " + "upper('%" + author +
"%')";
if (query.indexOf ("WHERE") == -1 )
query = query + "WHERE upper(Author) LIKE " + "upper('" + author +
"')";
else
query = query + "OR upper(Author) LIKE " + "upper('" + author + "')";
----- Original Message -----
From: Andrew Perepelytsya <>
To: <[EMAIL PROTECTED]>
Sent: Sunday, November 18, 2001 2:26 PM
Subject: Re: query based on multiple form fields
> --- mike dizon <[EMAIL PROTECTED]> wrote: > Hi All,
> >
> > I'm new to servlets. I was wondering how I would process a query based
on
> > multiple form fields. For example, if there was a field called firstName
> > and lastName, I wish to return results based on information from the two
> > different fields.
> >
> > Thanks!
> >
>
> just use:
>
> request.getParameter ("firstName"); <and>
> request.getParameter ("lastName");
>
> hope this helps :)
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page from News and Sport to Email
and Music Charts
> http://uk.my.yahoo.com
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html