How to join this 5 tables in mysql?
<p>I have 5 tables that I need to connect to get the necessary data.</p>

<p><strong>Table1</strong></p>

<pre><code>id | number
1  | 1
2  | 5
</code></pre>

<p><strong>Table 2</strong></p>

<pre><code>id | number | user_id
1  | 1      | 9
2  | 5      | 8
</code></pre>

<p><strong>Table 3</strong></p>

<pre><code>id | name | 
8  | john | 
9  | jane | 
</code></pre>

<p><strong>Table 4</strong></p>

<pre><code>id | email
6  | johndoe@example.com
</code></pre>

<p><strong>Table 5</strong></p>

<pre><code>id | table4_id | table3_id
1  | 6         | 8
</code></pre>

<p>Table 1 is my main table and I want to add the name and email from table 3 and 4 respectively to my select query of table 1, but in order to do so, I would need to use table 2 and 5 to connect them as there is no direct relationship between table 1 and table 3 and 4. I only know how to join 3 tables and not 5 tables and it seems confusing to me on how to proceed with this.</p>

<p>I followed the link <a href="https://stackoverflow.com/a/25580544/6444625">here</a> to join Table 1,2 and 3. But I don't know how to proceed with table 4 and 5.</p>

<p>This is the query I tried:</p>

<pre><code>SELECT table1.number, table2.number, table2.user_id, table3.id, table3.name,
table4.id, table4.email, table5.table4_id, table3_id
FROM table1
LEFT JOIN table2
    INNER JOIN table3
        //this query will work if I don't include this 2 inner joins
         INNER JOIN table4
            INNER JOIN table5
            ON table3.id = table5.table3_id
         ON table5.table4_id = table4.id
       //
      ON table2.user_id= table3.id
ON table2.number = table1.number;
</code></pre>

<p><strong>ERROR: (if included the inner join for table 4 and 5)</strong></p>

<blockquote>
  <p>Error Code: 1064. You have an error in your SQL syntax; check the
  manual that corresponds to your MySQL server version for the right
  syntax to use near 'ON table2.user_id= table3.id</p>
</blockquote>