Mark, Peter, The query below assumes that the user will search of FirstName and none or more of the other fields - which was not how the question reads (to me).
To answer the question it would be useful to know how you are accessing MySQL - are you using PHP (as per example code below) for example? When the form data is received it is (very) necessary to 'clean' and validate the data. Part of this process involves the question "was this field filled out?". Thus front end-processing is the time for the query's WHERE clause to be built up. The last question is going to be "has at least one field been filled out?"! The methodology of Peter's reply still applies. There are a number of tutorials available on various sites (but can't point you at one because don't know which tool you're using!!!). Would certainly recommend researching a few... Regards, =dn > $query = 'SELECT * > FROM Table > WHERE > FirstName LIKE "%'.$firstname.'%"' ; > if($lastname)$query.= ', AND LastName LIKE "%'.$lastname.'%"'; > if($region)$query.= ', AND Region LIKE "%'.$region.'%"'; > if($loan_officer)$query.= ', AND Loan_officer LIKE > "%'.$loan_officer.'%"'; > etc..... > > $mysql_result = mysql_query($query, $mysql_link); > > HTH > > Peter > > ----------------------------------------------- > Excellence in internet and open source software > ----------------------------------------------- > Sunmaia > www.sunmaia.net > [EMAIL PROTECTED] > tel. 0121-242-1473 > ----------------------------------------------- > > > -----Original Message----- > > From: Mark Stringham [mailto:[EMAIL PROTECTED]] > > Sent: 28 March 2002 17:21 > > To: MySQL > > Subject: SQL query question - using LIKE > > > > > > I have a simple search form that allows the user to search a contact db > > based on criteria that they choose. > > Search by - > > first name - text box > > last name - text box > > region - drop down > > loan officer - drop down > > > > I want the user to be able to receive results if they choose all possible > > criteria or just one criteria. > > My question is about query structure. How do I query the database when I > > have multiple criteria selected? > > > > > > Any help is appreciated. > > > > Mark > > > > > > --------------------------------------------------------------------- > > Before posting, please check: > > http://www.mysql.com/manual.php (the manual) > > http://lists.mysql.com/ (the list archive) > > > > To request this thread, e-mail <[EMAIL PROTECTED]> > > To unsubscribe, e-mail > > <[EMAIL PROTECTED]> > > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php