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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:19:05+00:00 2026-05-27T13:19:05+00:00

This question has been asked before but never really answered (at least the way

  • 0

This question has been asked before but never really answered (at least the way I want to do it). I have three tables in my database, threads, responses and votes. I need them to share the id field only. So I can do something like

SELECT * FROM threads AS t JOIN responses AS r JOIN votes AS v
WHERE id = 15

and will only retrieve a thread a response or (exclusive) a vote record with id = 15.

Is there a possible way to do this without creating an extra table? I’m not asking if it’s a good idea (which is probably not), but if it’s possible and how to do it.

  • 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-05-27T13:19:05+00:00Added an answer on May 27, 2026 at 1:19 pm

    Your select will throw an error, because the id field in the where clause is ambiguous. I suppose there is an id field in all of these three tables.

    SELECT * FROM threads AS t JOIN responses AS r JOIN votes AS v
    WHERE id = 15
    

    So even if the id field is “somehow shared” between these fields, you will have to make your where clause unambiguous:

    SELECT * FROM threads AS t JOIN responses AS r JOIN votes AS v
    WHERE t.id = 15
    

    Furthermore, I suppose threads and responses have a many-to-one relationship which means there can be several response corresponding to a single thread. This means the responses table would have a thread_id field. The id field in the responses table could not have the same value as the id field in the corresponding thread record, since the id field must be unique in both tables.

    The same logic goes to the relationship between responses and votes (a single response would have many votes).

    Hence I conclude there is no possible way to share the id field between these three tables.

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

Sidebar

Related Questions

Maybe this question has been asked many times before, but I never found a
This question has been asked before ( link ) but I have slightly different
This question has been asked before and there have been windows-specific answers but no
This question has been asked before but 1) the user never accepted an answer
So this question has been asked before , but not answered in great detail.
I know this question has been asked before but I seem to have a
This question has been asked before, but I can't find any answers that have
Perhaps this question has been asked before in a different way, but I haven’t
I know this question has been asked before but I have a design question
I know this question has been asked before, but I ran into a problem.

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.