Multiple inner joins with multiple tables

前端 未结 1 1808
自闭症患者
自闭症患者 2020-12-13 05:01

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

相关标签:
1条回答
  • 2020-12-13 05:24

    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 讨论(0)
提交回复
热议问题