title: mysql select from T1 if not in T2 else replace
body: <p>So mysql PDO query I am trying to write must compare columns from two tables and output array. </p>
  
  <ol>
  <li>If empty output data from table1  </li>
  <li>if cell has value same as table2,
      output that value as first and then all other values next.</li>
  </ol>
  
  <p>job table: </p>
  
  <pre><code>table1
  |jobName|Name|
  |job1   |John|
  |job2   |John|
  |job3   |John|
  |jobABC |Jack|
  |jobCCC |Jack|
  |jobXYZ |Jack|
  </code></pre>
  
  <p>and day table:</p>
  
  <pre><code>table2
  |day |jobName|Name|
  |day1|       |John|
  |day1|jobCCC |Jack|
  |day2|job2   |John|
  |day2|       |Jack|
  |day3|jobXYZ |Jack|
  |day3|job1   |John|
  </code></pre>
  
  <p>and the output for John should be:</p>
  
  <pre><code>day1, job1, job2, job3
  day2, job2, job1, job3
  day3, job1, job2, job3
  </code></pre>
  
  <p>and the output for Jack should be:</p>
  
  <pre><code>day1, jobCCC, jobABC, jobXYZ
  day2, jobABC, jobCCC, jobXYZ
  day3, jobXYZ, jobABC, jobCCC
  </code></pre>
  
  <p>Thanks!</p>