• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Search Appllication  RSS feed

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ford Darcy Jr
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add as many ANDs and ORs as you like to the SQL String.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have been able to solve the problem myself. Thanks for the responses.
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!