This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sql query

 
ankita balaji
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic