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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:37:23+00:00 2026-06-16T18:37:23+00:00

I have two tables I’m trying to join and get a unique value in

  • 0

I have two tables I’m trying to join and get a unique value in one column based on the max value of another column plus an identifier in another table. This is my structure.

Partial Table 1 (reward_webuid):
╔════╦═════════╦═════════╦══════════╦═════════════════════╦═════════╗
║ ID ║ WEB_UID ║ ITEM_ID ║ PLAYERID ║      TIMESTAMP      ║ EXPIRED ║
╠════╬═════════╬═════════╬══════════╬═════════════════════╬═════════╣
║  8 ║ 1209520 ║   73410 ║  1926406 ║ 2013-01-05 04:47:06 ║       0 ║
║  9 ║ 1209520 ║   73425 ║  1926406 ║ 2013-01-02 09:40:27 ║       1 ║
║ 10 ║ 1209520 ║   73424 ║  1926406 ║ 2013-01-05 09:40:05 ║       0 ║
║ 11 ║ 1209520 ║   73425 ║  1926406 ║ 2013-01-05 09:40:27 ║       0 ║
║ 12 ║ 1209521 ║   73424 ║ 21555896 ║ 2013-01-05 01:33:20 ║       0 ║
║ 13 ║ 1209521 ║   75000 ║  5599854 ║ 2013-01-05 01:35:09 ║       1 ║
╚════╩═════════╩═════════╩══════════╩═════════════════════╩═════════╝

Partial Table 2 (rewards):
╔═════════╦═════════════════╦══════════════╦═════════════╗
║ ITEM_ID ║ CUST_LOADOUT_ID ║ REWARD_LEVEL ║ EXPIRY_TIME ║
╠═════════╬═════════════════╬══════════════╬═════════════╣
║   73410 ║               1 ║            5 ║           0 ║
║   73424 ║               2 ║           10 ║           0 ║
║   73425 ║               3 ║           15 ║          30 ║
║   75000 ║               4 ║           50 ║          60 ║
╚═════════╩═════════════════╩══════════════╩═════════════╝

Sample return of what I would like to get (cust_loadout_id and playerID for the maximum value of reward level based on item_id in table 1 that hasn’t expired yet) there should only be one value per playerID

╔══════════╦═════════════════╗
║ PLAYERID ║ CUST_LOADOUT_ID ║
╠══════════╬═════════════════╣
║  1926406 ║               3 ║
║ 21555896 ║               2 ║
╚══════════╩═════════════════╝

Would be grateful if anyone could help with this. I searched and most queries related to the same table or 3 or more tables. The best I’ve managed is to return data I needed but it wasn’t ordered correctly

  • 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-16T18:37:24+00:00Added an answer on June 16, 2026 at 6:37 pm
    SELECT  a.*, b.*
    FROM    reward_webuid a
            INNER JOIN rewards b
                ON a.item_id = b.item_ID
            INNER JOIN
            (
                SELECT  aa.PLAYERID, MAX(bb.REWARD_LEVEL) maxLevel
                FROM    reward_webuid aa
                        INNER JOIN rewards bb
                            ON aa.item_id = bb.item_ID
                WHERE   aa.expired = 0
                GROUP   BY aa.PLAYERID
            ) c ON  a.PLAYERID = c.PLAYERID AND
                    b.REWARD_LEVEL = c.maxLevel AND
                    a.Expired = 0
    
    • SQLFiddle Demo
    • SQLFiddle Demo (selected columns only)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have two tables say ABC and XYZ and contain one column which data will
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables in my MySQL database, one is a library of all
I have two tables connected with one to many relationship. Parent Table is a
I have two tables one with an add button and one without an add
I have two tables; one with post data and in the other each row
I have two tables, with a same column named user_name , saying table_a ,
Have two sets of data (two tables) for patient records, one 1999-2003, the other
I have two tables which have a column in common, how can I retrieve
I have two tables from target website in database and have to get post

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.