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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:36:47+00:00 2026-05-24T23:36:47+00:00

So I have four tables. Each table has a single id for the previous

  • 0

So I have four tables. Each table has a single id for the previous table id. So my in click table has an id and an id for the ad from which it came. In the ad table, it has an id for the ad and one for the campaign it’s from. So here’s an example.

Table4 -
id   company      table_id
11     hp           20
12     apple        23
13     kohls        26  
14     target       21
15     borders      28

Table3 - 
id    value    table2_id
21     ks          53
22     al          54
23     tx          53 
24     fl          55
25     co          51

Table2 -
id    value    table1_id
51     ks          34
52     al          34
53     tx          33 
54     fl          35
55     co          31

Table1 -
id    value    
31     ks        
32     al          
33     tx          
34     fl          
35     co  

So to find out where the values in Table 4 came from, I need to work back through each table and check which id they have. Basically, I want to know which values in table 1 are associated with the values in table 4.

This of table 4 as visitors to a website and Table 1 as internet ads. I want to know which visitors came from which ads. Unfortunately, the data is set up so that I can only take single steps back from visitor to source to ad group to ad. Does that make sense?

Anyways, I’m wondering if using 4 innner joins was the optimal strategy for this problem or is there some simpler mysql solution that i’m not aware of.

  • 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-24T23:36:48+00:00Added an answer on May 24, 2026 at 11:36 pm

    Inner joins are probably the best method, and you only need 3.

    This will give you a result set with two columns: company and associated values.

    SELECT Table4.company, table1.id, table1.value
    FROM Table1
        INNER JOIN Table2
            ON Table2.table1_id = Table1.id
        INNER JOIN Table3
            ON Table3.table2_id = Table2.id
        INNER JOIN Table4
            ON Table4.table3_id = Table3.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables, table one (tableA) containing users data like name and email,
I have a model Goal that has four types of children (which all have
7 tables. In each table there is a common entity called fisherid. I have
Ok, I have four tables: Table 1: f_withholdings Table 2: f_wh_list Table 3: f_rpayments
I have a table that will have 500,000+ records. Each record has a LineNumber
I have four tables, each looks like ID Value 1 23.43 2 34.23 1
Ok I have two tables. Table IDAssoc has the columns bill_id , year ,
I have a table that stores various types of flags. Each flag type has
I have four tables containing exactly the same columns, and want to create a
I have four tables: Users PrivilegeGroups rdPrivileges LinkPrivilege ----------- ---------------- --------------- --------------- userId(pk) privilegeGroupId(pk)

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.