How do I avoid search problems when a user leaves a search box empty on an Ultradev search page running jserv and attached to a MySQL database?
I have three search boxes: Author, Title, and Keyword The user enters the search data into one, two, or all three of the fields, and presses "SUBMIT" (I use JSP), so the variables for the recordset are (ex. Author) : Name: varAuthor Default Value: % [I also tried 1 ] Run-Time Value: request.getParameter("txtAuthor") The search uses this SQL logic: SELECT Author, Title, Keyword FROM tbJose WHERE Author LIKE '%varAuthor%' OR Title LIKE '%varTitle%' OR Keyword LIKE '%varKeyword%'; The search works perfectly , UNLESS A USER LEAVES ONE BOX EMPTY, then the search RETURNS ALL RECORDS IN THE DATABASE, whether the default value is % or is 1. I do not want this to happen. How might I modify the code? I am a SQL beginner so I need explicit instructions. --------------------------------------------------------------------- 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