Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9103873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:44:00+00:00 2026-06-17T01:44:00+00:00

DB Table Structure: Session Table (aka Exam Table) SessionId(auto) SessionName 137 XULWQ Question Table:

  • 0

DB Table Structure:

Session Table (aka Exam Table)

SessionId(auto)  SessionName
137              XULWQ

Question Table:

SessionId  QuestionId QuestionContent  QuestionNo QuestionMarks  OptionId
137        1          Name 2 Things     1         5               5
137        2          Name 3 Things     2         5               2

Option_Table Table:

OptionId  OptionType
1         A-C
2         A-D
3         A-E
4         A-F
5         A-G
6         A-H

Answer Table:

 AnswerId(auto) SessionId  QuestionId  Answer
   200            137        1           B
   201            137        1           F
   202            137        2           D
   203            137        2           A
   204            137        2           C   

I am having trouble compiling the query below. I want to select the following fields undeneath in the query but the problem I am having is with my joins. If you look at the last join I am trying to retrieve OptionID from Option_Table Table but I have to go through the Answer table which doesn’t have that field. My problem is that I have 3 fields which actually rely on joining with the Question` Table.

My question is what is the correct way of joining the tables below so that it displays the answers for each question with the fields I want to SELECT?

SELECT q.SessionId, s.SessionName, q.QuestionId, q.QuestionNo, q.QuestionContent, an.Answer, an.AnswerId, q.QuestionMarks, q.OptionId, o.OptionType
       FROM Session s 
       INNER JOIN Question q ON s.SessionId = q.SessionId
       JOIN Answer an ON q.QuestionId = an.QuestionId
       JOIN Option_Table o ON an.OptionId = o.OptionId
       WHERE s.SessionName = ?
       ORDER BY q.QuestionId, an.Answer

Output required:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:44:01+00:00Added an answer on June 17, 2026 at 1:44 am
    SELECT * 
    FROM Question q 
        INNER JOIN Answer a ON q.QuestionID = a.QuestionID
        INNER JOIN Option_Table ot ON ot.optionID = q.optionID
        INNER JOIN session s ON s.sessionid = q.sessionid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DB Table Structure: Session Table (aka Exam Table) SessionId(auto) SessionName 137 XULWQ Question Table:
I have a table (session_comments) with the following fields structure: student_id (foreign key to
Table structure id (p) | date | id2 (fk) | id3 (fk) where (p)
Table structure- int PrimaryKey DateTime Date int Price What I would like to do
Table structure goes something like this: Table: Purchasers Columns: id | organization | city
My table structure is below: CREATE TABLE [ACC].[Document]( [DocumentID] [int] IDENTITY(1,1) NOT NULL, [Date]
My table structure is below : MyTable (ID Int, AccID1 Int, AccID2 Int, AccID3
My table structure in the database; Table System_t id | Owner | System ===========================================
My table structure is: TABLE `licenses` ( `id` int(11) NOT NULL auto_increment, `code` varchar(30)
Simplified Table structure: CREATE TABLE IF NOT EXISTS `hpa` ( `id` bigint(15) NOT NULL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.