aspose file tools*
The moose likes JDBC and the fly likes Sql query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Sql query" Watch "Sql query" New topic
Author

Sql query

ankita balaji
Greenhorn

Joined: Aug 19, 2004
Posts: 11
Hai friends,
Good Evening.Im new to SQL database and need a small help from you.Actually,I hav some questions posted in my database which are having 4 answers each.Now,can anyone please tell me the format of query of retreiving these multiple answers for the questions.
Expecting help from you,
Thanking you,
Ankita
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
According to the scenerio there should be two tables one for Questions and te other is for Answers.

Tables
------

Question
Answer

there should be one to many relationship between Question and Answer. Assuming tables,


Question
--------

ID(pk) QUESTION
------ --------



ANSWER
--------

ID(pk) QUES_ID(fk) ANSWER
------ -------- ------



query looks like this.

-----------------
select ANSWER
from ANSWER
where QUES_ID = 'ANY'
-------------------------

or use equi-join to join both tables
[ October 05, 2004: Message edited by: adeel ansari ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sql query