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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:47:43+00:00 2026-05-13T10:47:43+00:00

I have the following problem to solve: Let’s say there is a table A

  • 0

I have the following problem to solve:

Let’s say there is a table A that contains an number of elements, this table is copied to become table B. In table B some of the original elements are lost and some are added. A reference table AB keeps track of these changes. Then table B is copied to be table C and again some of the existing elements get lost and some are added. Another reference Table BC keeps track of these relations. … etc.

There is an n number of such tables with an n-1 number of reference tables.

If I want to know which of the elements of my choice in table C where already present in A, I can do that by doing something like:

SELECT AB.oldID
FROM AB
JOIN BC
WHERE BC.newID IN (x, y, z)

Now since the number of reference tables can wary, the number of JOIN lines can wary.

Should I concatenate the query by looping over the steps and adding JOIN lines or shoudl I rather write a recursive function that selects only the members of the next step and then let the function call itself until I have the end result?

Or is there an other even better way to do something like that?

  • 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-13T10:47:43+00:00Added an answer on May 13, 2026 at 10:47 am

    Since your table names vary, you’ll need to build some kind of a dynamical query.

    If you do the recursive function approach, you’ll need to pass the resultsets between the function calls somehow.

    MySQL has no array datatype, and storing the results in a temp table is way too long.

    Conclusion: use joins.

    Update:

    Here’s a sample query which returns the entries that persisted through revision A to revision M (with one table design):

    SELECT  *
    FROM    entries e
    WHERE   NOT EXISTS
            (
            SELECT  *
            FROM    revisions r
            JOIN    revision_changes rc
            ON      rc.revision_id = r.id
            WHERE   rc.entry_id = e.id
                    AND rc.deleted
                    AND r.revision_id BETWEEN 'A' AND 'M'
            )
    

    This way, you just fill the added and deleted fields of revision_changes for the revisions where the entry was added or deleted.

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

Sidebar

Related Questions

Avast there fellow programmers! I have the following problem: I have two rectangles overlapping
I have the following problem: I have an HTML textbox ( <input type=text> )
I have the following problem using subversion: I'm currently working on the trunk of
I have the following problem using template instantiation [*]. file foo.h class Foo {
I have the following problem in my Data Structures and Problem Solving using Java
I have the following problem: I open the dialog, open the SIP keyboard to
I have the following problem. If I query values with a keyfigure which is
I have got the following problem since the server has safe mode turned on,
Has anyone encountered the following problem: I have IIS7 running on my computer. On
When writing GUIs, I've frequently come over the following problem: Assume you have a

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.