This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Search Appllication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Search Appllication" Watch "Search Appllication" New topic
Author

Search Appllication

ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi,

I need to develop a search application in which the user can select from the existing list of drop downs. The user should be given a provision to select either one of the drop downs or a combination of drop downs. I am developing this application using servlets. Can anybody please let me know the sql string which will enable the user to search based on one or combination of drop down columns.

Thanks.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hmm. Without knowing anything about your data model, all I can say is your SQL will probably include some "LIKEs", some "ORs" and the odd "IN". Unless you tell us more, thats as clear as I can be.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi Paul,

Thanks for ur response. I tried using OR and Like's but the problem is I need to retrieve only those values which match that particular criteria. I have around 3 drop down boxes and the user can select either all 3 or can select only 2 of them or may be only one. In this kind of a scenario, only those values which match all 3 drop downs or all 2 drop downs or just that one drop down selection has to be retrieved. When I use OR...I am getting duplicate records.

Can you please let me know where am I going wrong.

Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can add as many ANDs and ORs as you like to the SQL String.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by ford Darcy Jr:

When I use OR...I am getting duplicate records.


You may want to read up on SQLs 'DISTINCT' keyword.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Can you please let me know where am I going wrong.

You are not telling us anything about your data model. Why don't you try posting a description of your table strucutre, then perhaps we can offer some more constructive help.
ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi,

I have been able to solve the problem myself. Thanks for the responses.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Search Appllication