title: SQL JOIN many-to-many
body: <p>Sorry about the minimalistic title but I don't know how to describe it in short. I have three tables:</p>
  
  <p>The table of groups</p>
  
  <pre><code>ID | Genre
  -----------------
  1  | Action
  2  | Adventure
  3  | Drama
  </code></pre>
  
  <p>Many to many table</p>
  
  <pre><code>GroupID | ElementID
  -----------------
      3   |    1
      1   |    2
      2   |    2
      2   |    3
      3   |    3
  </code></pre>
  
  <p>And the table of elements</p>
  
  <pre><code>ID | Element
  -----------------
  1  | Pride and Prejudice
  2  | Alice in Wonderland
  3  | Curious Incident Of A Dog In The Night Time
  </code></pre>
  
  <p>All is fine and very simple. The SELECT I am trying to achieve is the following</p>
  
  <pre><code>ID | Element                                         |  Genre
  -------------------------------------------------------------
  1  | Pride and Prejudice                             | Drama
  2  | Alice in Wonderland                             | NULL
  3  | Curious Incident Of A Dog In The Night Time     | Drama
  </code></pre>
  
  <p>I want to select <strong>all</strong> the elements from the table Elements and set the genre field to <strong>Drama</strong> or <strong>null</strong>.</p>
  
  <p>I'm trying to do this in <strong>MySQL</strong>.</p>
  
  <p>Thank you in advance</p>