title: MySQL Join Multiple (More than 2) Tables with Conditions
body: <p>Assume I have 4 tables:</p>
  
  <p>Table 1:  <code>Task</code></p>
  
  <pre><code>ID     Task            Schedule
  1      Cut Grass         Mon
  2      Sweep Floor       Fri
  3      Wash Dishes       Fri
  </code></pre>
  
  <p>Table 2:  <code>Assigned</code></p>
  
  <pre><code>ID     TaskID (FK)     PersonID (FK)
  1          1                1
  2          1                2
  3          2                3
  4          3                2
  </code></pre>
  
  <p>Table 3:  <code>Person</code></p>
  
  <pre><code>ID     Name
  1      Tom
  2      Dick
  3      Harry
  </code></pre>
  
  <p>Table 4:  <code>Mobile</code></p>
  
  <pre><code>ID     PersonID (FK)     CountryCode     MobileNumber
  1          1                 1           555-555-5555
  2          2                44           555-555-1234
  3          3                81           555-555-5678
  4          3                81           555-555-0000
  </code></pre>
  
  <p>I'm trying to display the</p>
  
  <ol>
  <li>Task on a certain day</li>
  <li>Name of person assigned to task</li>
  <li>Phone numbers of said person</li>
  </ol>
  
  <p>I think it should be something like the following, but I'm not sure how to set up the conditions so that the results are limited correctly:</p>
  
  <pre><code>SELECT T.ID, T.Task, P.Name, M.MobileNumber
  FROM Task AS T
  LEFT JOIN Assigned AS A
       ON T.ID = A.TaskID
  LEFT JOIN Person AS P
       ON A.PersonID = P.ID
  LEFT JOIN Mobile AS M
       ON M.PersonID = P.ID
  WHERE T.Schedule = Fri
  </code></pre>
  
  <p>My goal is to fetch the following information (it will be displayed differently):</p>
  
  <pre><code>Tasks                        Name             MobileNumber
  Sweep Floor, Wash Dishes     Dick, Harry      44-555-555-1234, 81-555-555-5678, 81-555-555-0000
  </code></pre>
  
  <p>Of course, if JOIN is the wrong way to do this, please say so.</p>