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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:59:07+00:00 2026-05-26T00:59:07+00:00

I’ve got an interesting dilemma now. I have a database schema like the following:

  • 0

I’ve got an interesting dilemma now. I have a database schema like the following:

GameList:
+-------+----------+-----------+------------+--------------------------------+
|  id   | steam_id | origin_id | impulse_id |           game_title           |
+-------+----------+-----------+------------+--------------------------------+
|   1   |   17450  |   NULL    |    NULL    |      Dragon Age: Origins       |
|   2   |   NULL   | 138994900 |    NULL    |    Dragon Age(TM): Origins     |
|   3   |   NULL   |   NULL    |  dragonage |      Dragon Age Origins        |
|   4   |   47850  | 201841300 |  fifamgr11 |        FIFA Manager 11         |
|  ...  |   ...    |    ...    |     ...    |              ...               |
+-------+----------+-----------+------------+--------------------------------+

GameAlias:
+----------+-----------+
|  old_id  |  new_id   |
+----------+-----------+
|    2     |     1     |
|    3     |     1     |
|   ...    |    ...    |
+----------+-----------+

Depending on whether the stores use the same title for the game there may be no issues, or there may be multiple rows for the same game. The Alias table exists to resolve this issue, by stating that id 2 and id 3 are just aliases for id 1.

What I need is an SQL query which uses both the GameList table and the GameAlias table and returns the following:

ConglomerateGameList:
+-------+----------+-----------+------------+--------------------------------+
|  id   | steam_id | origin_id | impulse_id |           game_title           |
+-------+----------+-----------+------------+--------------------------------+
|   1   |   17450  | 138994900 |  dragonage |      Dragon Age: Origins       |
|   4   |   47850  | 201841300 |  fifamgr11 |        FIFA Manager 11         |
|  ...  |   ...    |    ...    |     ...    |              ...               |
+-------+----------+-----------+------------+--------------------------------+

Note that I want the game title of the “new id”. The game title for any “old ids” should simply be discarded/ignored.

I would also like to note that I can’t make any modifications to the GameList table to solve this issue. If I were to simply re-write the table to look like my desired output then every night when I grab an updated game list from the stores it would fail to find the game in the database, generating yet another row like so:

+-------+----------+-----------+------------+--------------------------------+
|  id   | steam_id | origin_id | impulse_id |           game_title           |
+-------+----------+-----------+------------+--------------------------------+
|   1   |   17450  | 138994900 |  dragonage |      Dragon Age: Origins       |
|   4   |   47850  | 201841300 |  fifamgr11 |        FIFA Manager 11         |
|  ...  |   ...    |    ...    |     ...    |              ...               |
|  8139 |   NULL   | 138994900 |    NULL    |     Dragon Age(TM): Origins    |
|  8140 |   NULL   |    NULL   |  dragonage |      Dragon Age Origins        |
+-------+----------+-----------+------------+--------------------------------+

I also can’t work on the assumption that a game’s id will never change as Steam has been known to change them when a major update to the game is released.

Bonus points if it can recognize recursive aliases, like the following:

GameAlias:
+----------+-----------+
|  old_id  |  new_id   |
+----------+-----------+
|    2     |     1     |
|    3     |     2     |
|   ...    |    ...    |
+----------+-----------+

Since id 3 is an alias for id 2 which itself is an alias for id 1. If recursive aliases is impossible then I can just develop my application logic to prevent them.

  • 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-26T00:59:08+00:00Added an answer on May 26, 2026 at 12:59 am

    Does this work? Correct the table names.

    select ga1.new_id, max(gl1.steam_id), max(gl1.origin_id), max(gl1.impulse_id),
    max(if(gl1.id = ga1.new_id,gl1.game_title,NULL)) as game_title
    from gl1, ga1
    where (gl1.id = ga1.new_id OR gl1.id = ga1.old_id)
    group by ga1.new_id
    
    union
    
    select gl2.id, gl2.steam_id, gl2.origin_id, gl2.impulse_id, gl2.game_title
    from gl2, ga2
    where (gl2.id not in (
        select ga3.new_id from ga3
        union
        select ga4.old_id from ga4))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I have a reasonable size flat file database of text documents mostly saved in
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.