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

  • Home
  • SEARCH
  • 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 605143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:06:51+00:00 2026-05-13T17:06:51+00:00

Here is an example of the data set I am working with. I am

  • 0

Here is an example of the data set I am working with. I am trying to write a query that will allow me to request a row from the items table, and display the User Name from the users table in place of the user ids:

Table 1 - users table

User ID | User Name 
--------------------
12      | Fred
13      | Ted
14      | Ned

Table 2 - items Table

Item ID | Submitted User | Assigned User
----------------------------------------
234     | 12             | 14
345     | 12             | 13
456     | 14             | 12

This is as far as I can get, which returns one properly labled username:

SELECT users.[user name] AS [Submitted User] FROM items 
JOIN users ON items.[Assigned User] = users.[User ID]
WHERE items.[Item ID] = '234'

The problem with this is that while ONE field works, I need to get both the submitted user AND the assigned user. I am trying to do it in one query… I have a feeling it can be done but I just don’t know exactly how. If I try to assign the fields more than once I get an error about correlation. Here is an example of what I tried that gives a correlation error:

SELECT users.[user name] AS [Submitted User], users.[user name] AS [Assigned User] FROM items 
JOIN users ON items.[Submitted User] = users.[User ID]
JOIN users ON items.[Assigned User] = users.[User ID]
WHERE items.[Item ID] = '234'

This is exactly what I’m trying to do:

SELECT 
  items[Submitted User].users.[user name] AS [Reported User],
  items[Assigned User].users.[user name] AS [Assigned User] 
WHERE items.[Item ID] = '234'</pre>

This is the response I’m trying to get:

Submitted User | Assigned user
Fred           - Ted
  • 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-13T17:06:52+00:00Added an answer on May 13, 2026 at 5:06 pm

    You want to alias your JOIN table so that you can join against it twice. See below:

    SELECT 
        submitted.[user name] AS [Submitted User], 
        assigned.[user name] AS [Assigned User] 
    FROM items 
        LEFT JOIN users submitted ON items.[Submitted User] = submitted.[User ID]
        LEFT JOIN users assigned ON items.[Assigned User] = assigned.[User ID]
    WHERE items.[Item ID] = '234'
    

    Some other suggestions:

    • Table 2’s column names should be Submitted User ID, Assigned User ID to make it more explicit that you’re joining IDs.
    • You might want to make your ID fields INT. It makes for faster joins and less space.
    • Don’t forget to build indices on the ID fields on both tables so the JOIN can take advantage of them.
    • Thanks astander, changed join to LEFT JOIN since you probably want to see the results
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting an error here that says I haven't defined a method, but it
This is beyond both making sense and my control. That being said here is
I have found this example on StackOverflow: var people = new List<Person> { new
I am writing a query to fetch results for all the values in a
Let say I have the following desire, to simplify the IConvertible's to allow me
There doesn't seem to be any tried and true set of best practices to
IE is giving me an undefined NAN when i try to view the calender...
I would like to remove/delete a migration file. How would I go about doing

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.