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 8588781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:53:17+00:00 2026-06-11T22:53:17+00:00

I have 3 tables: tbl_question (id,question) tbl_answer (id,answer) question_has_answer (id,question_id,answer_id) It looks like many-to-many

  • 0

I have 3 tables:

tbl_question (id,question)
tbl_answer (id,answer)
question_has_answer (id,question_id,answer_id)

It looks like many-to-many association, but in fact it is only used like 1-to-many (one question has multiple answers, but each answer belongs to only question). So I need to get fields (except id) from first and second table like this:

Question1
      answer1
      answer2
      answer3
Question2
      answer5
      answer4

and so on.

  • 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-11T22:53:18+00:00Added an answer on June 11, 2026 at 10:53 pm

    Would be:

    SELECT question, answer
        FROM tbl_question q 
        INNER JOIN question_has_answer qha
        ON q.id = qha.question_id
        INNER JOIN tbl_answer a
        ON qha.answer_id = a.id
    ORDER BY question,answer
    

    I would also recommand not using an ID for table question_has_answer, if you don’t plan to use that ID.

    And further more: if 1 answer is associated with only 1 question, than you shouldn’t use question_has_answer and modify tbl_answer to add a questionID column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found the answer to my question, but in the wrong format. Using
I have 3 tables with values like below **tbl_product** recID pID price colour 1
android noob... I have two tables, with a one to many relationship between country_tbl
Background I have an Android project that has a database with two tables: tbl_question
I have a question of interest: I have 2 tables in mysql with InnoDb
Ok I have a question and it is probably very easy but I can
I've been searching and searching google for answers to my question but have been
I have the following tables: 1) TBL (ID, Data, LastUpdated, DateCreated) 2) TBL_LOG(Log_ID, LogCreateDate,
I have two tables, tbl_foo and tbl_bar , and I want to join these
I have 10 tables in my database(MySQL). two of them is given below tbl_state

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.