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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:26:18+00:00 2026-06-09T14:26:18+00:00

I have two different tables, my first table contains the authorizations granted to other

  • 0

I have two different tables, my first table contains the authorizations granted to other requests. It has the following columns:

Authorizations table

| authorization_date | role_id | request_id |
|--------------------|---------|------------|
| 2011-08-02         |    1    | 168        |
| 2011-08-10         |    2    | 168        |
| 2011-08-20         |    6    | 168        |
| 2011-08-03         |    2    | 169        |
| 2011-08-24         |    6    | 169        |
| 2011-08-05         |    3    | 170        |
| 2011-08-09         |    5    | 170        |

As you can see, different people have different roles and also can grant a certain level of authorization. The higher the role, the higher the request has been processed.
Now, what I want to do is I want to show the description associated to the role_id (which is in another table) and ONLY the last authorization. Since I have the date for it I already know which one is the latest one. However I don’t know how to do this as I try to group my query by getting the maximum value of the date, when I link it to my second table containing only the description of the role_id, I get duplicates and I just can’t think of a way to do this, I’m kind of new with queries & as I’ve been learning by myself I don’t know many things. Any ideas?

Thanks!

  • 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-09T14:26:19+00:00Added an answer on June 9, 2026 at 2:26 pm

    I am guessing a little here, but I think you want:

    SELECT Authorizations.*, anotherTable.description
    FROM 
    (
        SELECT MAX(authorization_date) AS max_date, request_id
        FROM Authorizations
        GROUP BY request_id
    ) last_auths
    INNER JOIN Authorizations ON last_auths.max_date = Authorizations.authorization_date
        AND last_auths.request_id = Authorizations.request_id
    INNER JOIN anotherTable ON anotherTable.role_id = Authorizations.role_id
    

    The derived table will get the maximum authorization date for each request. Then you can join to get the role_id for that request and join again to get the description.

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

Sidebar

Related Questions

I have two tables, both with the same columns. The first table contains original
I need to join two tables based on columns with different types. The first
I have a table with three columns; the first column contains IDs and the
My database has two tables, one contains a list of users, the other a
I have two tables like the following hotels ------ hotelID hotelName Second table operators
I have two different tables, lead and click. I would like to query MySQL
I have two different tables from which I need to pull data blogs which
I have an HTML document where I have two different tables. One is class
I have two tables, both named as say, Employee in two different schema HR
i have two tables one is called addons and holds information about different addons,

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.