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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:26:52+00:00 2026-05-23T19:26:52+00:00

Two questions. One: How would I be able to join two tables together, which

  • 0

Two questions.

One: How would I be able to join two tables together, which are not the original FROM ‘x’ table?

Example: Grabbing all the reports and that users level name.

Report            
id | user_id      
1    1

User            
id | level_id      
1    1

Level            
id | level_name      
1    Admin

SELECT      report.id,
            report.user_id,
            level.name
FROM        report
INNER JOIN  user
ON          report.user_id=user.id
INNER JOIN  level
ON          user.level_id=level.id

Doesn’t seem to work.

Two: How to join tables not from a 1-1 but a 1-many?

Say I wanted to:

SELECT * FROM user JOIN report ON user.id=report.user_id WHERE user.id='4'

But only join with the most recent report ordered by date desc?

I know it seems like I am asking you to do my work for me, but I just need to know what to use to accomplish this, not necessarily you coding it. Thanks.

UPDATE:

First question: Fixed, thanks
Second question:

I’ll show you my query to make better sense, I didn’t explain it well. I meant a many-many relationship where I grab a list of users and their latest report!

SELECT
    user.id
FROM 
    user
<< INNER JOINS ON OTHER TABLES >>
INNER JOIN
    (
        SELECT 
            report.id
        FROM
            report
        WHERE user.id=report.user_id
        ORDER BY
            date
        DESC
        LIMIT 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-05-23T19:26:53+00:00Added an answer on May 23, 2026 at 7:26 pm

    For your second question:

    MySQL-style:

    SELECT *
    FROM user
    INNER JOIN report re
      ON re.id = (SELECT id 
                  FROM report 
                  WHERE user_id=user.id 
                  ORDER BY report.date DESC
                  LIMIT 1)
    WHERE user.id='4'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got two questions (of which at least one is regarding RTTI in D2010
One of those classic programming interview questions... You are given two marbles, and told
The question has two parts, one of which I already have the answer for.
I have two systems I'd like to integrate, one which uses a completely in-house
I'm trying to solve questions from Project Euler in Ruby one-liners, and I'm curious
While researching the use of Table Hints , I came across these two questions:
I have two String.printable mysteries in the one question. First, in Python 2.6: >>>
This is kinda....a two part question. The first one is much more important than
My question is related to the following two: Emacs - Multiple columns one buffer
Possible stupid question: let's say I have two apps contained within one project. Can

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.