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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:37:55+00:00 2026-06-13T16:37:55+00:00

I have 4 tables which were auto generated for me: User Challenge Exercise Challenge_Exercise

  • 0

I have 4 tables which were auto generated for me:

  • User
  • Challenge
  • Exercise
  • Challenge_Exercise

One User may have many Challenges, and one Challenge will have many Exercises.

What I noticed is that the Challenge table has a reference to it’s parent User (called user_id) but Exercise do not have a reference in it’s table to Challenge; their relation is stored in Challenge_Exercise as Challenge_id and exercise_id.

My question is, how would I take out every Exercise that is linked to a specific user? For instance User with id = 1?

  • 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-13T16:37:56+00:00Added an answer on June 13, 2026 at 4:37 pm
    SELECT *
    FROM   excerise,
           challenge_excerise,
           challenge
    WHERE  challenge.user_id = 1
           AND challenge_excerise.challenge_id = challenge.id
           AND challenge_excerise.exercise_id = excercise.id
    

    What I’m doing here is a join, you could also explicitly do it with inner joins (google it if you wanna know more).

    This table is needed because you have a many to many relationship, which means each challenge can have multiple exercises, but also each exercise can have multiple challenges. It’s a standard to make an extra table then, so you don’t have redundant data, this table is often called junction table.

    If you want background just google it, there are tons of data to this topic.

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

Sidebar

Related Questions

I have two tables which have some transactional stuff stored in them. There will
I have three tables which are defined as: class User(Base): __tablename__ = 'users' id
I have several database tables in one database. The user inputs data to be
Hi I have a field in mySql table called jobnumber which auto increments with
I have the following hsqldb table, in which I map UUIDs to auto incremented
I have 3 tables which need to be linked in an SQL statement (I'm
I have 2 tables which I want to query from. The first table (lets
I have two tables which looks something like this Table Queue int ID; string
I have two tables which are used to store details of different types of
I have two tables which I want to join together using a left outer

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.