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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:14:22+00:00 2026-06-14T02:14:22+00:00

I have a mapping table that can hold IDs from the same table. For

  • 0

I have a mapping table that can hold IDs from the same table.

For example I have :

Variables ( Table )
Values ( Table)
Variables_Values ( Mapping table )

The mapping table has the following fields :

VariableID
To_VariableID
To_ValueID

So it is possible for a row to have two variable IDs, or a variable ID and a value ID.
It is always a pair, so there cannot be two variable IDs and a value ID at the same time.

Now, in the Variables and Values tables, there is a Name field, so variables and values also have names.

I want to create a query that will display the names based on the IDs in the mapping table, but I am not sure how.

Right now I have a query that returns results that look like this :

VariableName To_VariableID To_ValueID

I would like to display VariableName_2, ValueName instead of To_VariableID To_ValueID.

Is there a technique for this?
Could it be a combination of the following queries?

SELECT map.ID, map.TransitionID, variable.Name
FROM Variables AS variable INNER JOIN Mapping AS map 
ON variable.VariableID = map.VariableID

SELECT variable.VariableID, variable.Name
FROM Variable AS variable
WHERE variable.VariableID IN ( SELECT map.To_VariableID FROM Mapping AS map)

SELECT value.Name
FROM Values AS value
WHERE value.ValueID IN ( SELECT map.To_ValueID FROM Mapping AS map)

Thank you.

  • 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-14T02:14:24+00:00Added an answer on June 14, 2026 at 2:14 am

    It was as simple as this :

    SELECT map.Transition_Set_Variable_ID, 
           map.Transition_ID,
           variable.Name,
           variable2.Name,
           value.Name
    FROM Variables AS variable 
      INNER JOIN Mapping AS map ON variable.VariableID = map.VariableID
      LEFT JOIN Variables AS variable2 ON map.To_VariableID = variable2.VariableID
      LEFT JOIN Values AS value ON tsv.To_ValueID = value.ValueID
    ORDER BY map.TransitionID, variable.VariableID 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that are related via a mapping table: keywords titles I
I have the following mapping: @Entity @Table(name = Prequalifications) public class Prequalification implements Serializable
I have the following mapping for my table in MySql: <class name=Tag, namespace table=tags
I have the following code in my context, and no explicit table-class mapping, yet
I have a Website table that has a foreign key to a Client table.
I have a product table that has a many-to-many relation to itself (using a
I have a table with a one to many mapping to a table that
We're designing a database that has a simple table called Person. Each person can
I have a table with one field that can point to a foreign key
I have a table that hold records of part numbers for a specific project

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.