title: Mysql Query Join two table Order by one table column
body: <p>I have two table (table 1 and table 2) . I want to show all the rows from table1 by joining with table2 which have multiple rows with same table1 id (foreign key relation) and will sort the result by table2 priority column (order by desc). </p>
  
  <p>Table1</p>
  
  <p><img src="https://i.stack.imgur.com/2Wq8a.png" alt="enter image description here"></p>
  
  <p>Table2</p>
  
  <p><img src="https://i.stack.imgur.com/zXYk7.png" alt="enter image description here"></p>
  
  <p>Result will be</p>
  
  <p><img src="https://i.stack.imgur.com/zKPLC.png" alt="enter image description here"></p>
  
  <p>thanks in advance </p>
  
  <p>Edit</p>
  
  <pre><code>Table1
  
  id   name
  
  1   test1 
  2   test2
  3   test5
  4   test7
  5   test9
  6   test3
  
  
  Table2
  
  
  id  table1_id   event   priority
  
  1   2             abc      0
  2   2             kbc      0
  3   2             abc      2
  4   2             kbc      1
  5   4             fgg      2
  6   4             dss      3
  7   1             fgfg     2
  8   5             fgfg     2
  9   6             xcxc     1
  10  6             fgfh     3
  
  Result
  
  id_table1   name    event   priority
  
  4   test7   dss     3
  6   test3   fgfh    3
  2   test2   abc     2
  1   test1   fgfg    2
  5   test9   fgfg    2
  3   test5   NULL    NULL
  </code></pre>