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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:30:09+00:00 2026-06-18T00:30:09+00:00

I am trying to pull 2 different sets of data off of 1 table.

  • 0

I am trying to pull 2 different sets of data off of 1 table. I am not quite sure how to approach this though. This is the current table set up (that pertinent).

+----+-----------+----------+------+------------+--------+--------+
| id | recipient | given_by | time | expiration | points | reason |
+----+-----------+----------+------+------------+--------+--------+
|  1 |   72      |     1    | time |    time    |   2    |  test  |
|  3 |   15      |     4    | time |    time    |   5    |  test  |
+----+-----------+----------+------+------------+--------+--------+

+----+----------+
| id | username |
+----+----------+
| 1  |   admin  |
| 4  |   user4  |
...
| 15 |  user15  |
...
| 72 |  user72  |
+----+----------+

I was able to get the recipient to match up to a name by using this query:

SELECT 
   usr.username, usr.id,  sl.recipient, sl.given_by, 
   sl.time, sl.experation, sl.points, sl.reason
FROM 
    DD_users AS usr
LEFT JOIN
    DD_schittlist AS sl
ON (sl.recipient = usr.id)       
GROUP BY
        usr.id
ORDER BY 
        sl.points DESC,
        usr.username

That will match up recipient 72 to user72 but I also want to make given by 1 to show admin and given_by 4 to show as user4.

  • 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-18T00:30:11+00:00Added an answer on June 18, 2026 at 12:30 am

    You need to join twice against the DD_users table, once for id as you already have, and another for given_by. Each gets its own alias, which must be used in the SELECT list to disambiguate them (usr, given)

      SELECT 
        /* The original username you already had */
        usr.username, 
        usr.id,  
        sl.recipient, 
        sl.given_by, 
        /* The given_by username from the given alias table */
        /* Be sure to alias this column here as well to differentiate them in the client */
        given.username AS given_by_username,
        sl.time, 
        sl.experation, 
        sl.points, 
        sl.reason
      FROM 
        DD_users AS usr
        /* First join you already had between id and recipient */
        LEFT JOIN DD_schittlist AS sl ON (sl.recipient = usr.id)       
        /* A second LEFT JOIN between DD_shittlist and DD_users as given */
        /* (LEFT JOIN permits nulls in DD_shittlist.given_by) */
        LEFT JOIN DD_users AS given ON sl.given_by = given.id
      GROUP BY
        usr.id
      ORDER BY 
        sl.points DESC,
        usr.username
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to pull different data scenarios from my table
I'm trying to pull data from the YouTube API into a local MySQL table.
I am trying to pull a specific set of records from a table called
Just trying to pull off some SMART info from connected Hard Drives on any
I'm trying to pull some data out of logs on remote machines using awk,
I'm trying to pull a project from git, in particular, this one: https://github.com/pocmo/Yaaic .
I am trying to pull in the users table and if the email is
I'm trying to pull out page source from a set of pages and run
I'm very new to Javascript and JQuery, I've been trying different ways to pull
I am trying to get a Java desktop application to pull some data from

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.