File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Select Query with Comma Seperated Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Select Query with Comma Seperated Value" Watch "Select Query with Comma Seperated Value" New topic
Author

Select Query with Comma Seperated Value

Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Dear Ranchers,
I'm doing a project in JSP and MySQL. In my page there is a text box and a submit Button named Search.

When I enter in the textbox "Aravind,23,male".. it has to go into the database and has to search for "Aravind" whose age is "23" and sex is "male" and has to display the output

When I enter in the textbox "Aravind" it has to go into the database and has to search for all "Aravind" and has to get the result

When I enter "23" it has to bring all the name, whose age is equal to "23"

How can i do this in JSP and MySQL

My table design is like this



Please help me Ranchers, I want to show the demonstration before tomorrow evening.

Kind Regards

Aravind Prasad
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

One question: if you are managing an entity that has three distinct attributes, why did you choose to manage it via a single text area? Would three seperate form elements not be a better strategy?

Assuming you can't change the requirements, you have to first split the input into its three parts. This is fairly easy, looking at the JavaDocs for String will give you a way (it is slightly complicated because your requirements allow garbage input, but you can work round that).

Beyond that - what you are asking seems to be code written for you, which is not what we do here. What parts don't you understand? What have you written so far?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Thankyou very much for your reply.

But what i'm asking is exactly the searching in orkut. How can we do like that.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

and the question remains: why implement it in a way that is not useful when it can be improved on? Are you planning on being 'just as good as orkut' or better?
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Dear David,
Thanks for the reply. I'm not going to start something like orkut. But I'm currently working in a project which can search everything. for egs.

Q1) Place where I can get a spaner size 32 in California
Q2) Cardiology specialist, whose consultation fees is $50
Q3) Where can I fix puncher of my new Pajero with in $2.

These kind of funny funny questions. This is the project which I'm currently doing.

in the text box i will enter

Q1) spanner,size 32, California and press search
Q2) Doctor,Cardiology, $50
Q3) Workshop,puncher,Pajero,$2

Something like this..

Please help me to solve this problem..... How exactly I can search the details..

I hope Ranchers can help me like anything in this..

regards

Aravind Prasad
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Allowing random free text searches against a database is difficult, because of the structure of data in relational databases. Have you considered an IR (Information Retrieval) system such as Lucene? It might suit your requirements better.
 
 
subject: Select Query with Comma Seperated Value