title: Why my right join isn't working?
body: <p>I need to show all categories, even categories with no items.</p>
  
  <p>I have this query.</p>
  
  <pre><code>SELECT
          i.id,
          incident_active 'Approved',
          incident_verified 'Verified',
          category_title 'Category',
          ParentCategory 'Parent Category'
      FROM
          incident i
              INNER JOIN
          incident_category ic ON i.id = ic.incident_id
              RIGHT JOIN
          incident_person ip ON i.id = ip.incident_id
              RIGHT JOIN
          (SELECT
              c1.id,
                  c1.parent_id,
                  c2.category_title ParentCategory,
                  CONCAT_WS(' -&gt; ', c2.category_title, c1.category_title) category_title
          FROM
              category c1
          left outer join category c2 ON c1.parent_id = c2.id WHERE c1.parent_id != 0) AS c ON c.id = ic.category_id
      WHERE incident_dateadd &gt; DATE_SUB(NOW(), INTERVAL 1 MONTH)
  </code></pre>
  
  <p>which return:</p>
  
  <p><img src="https://i.stack.imgur.com/GeLHq.png" alt="enter image description here"></p>
  
  <p>and this query:</p>
  
  <pre><code>SELECT
              c1.id,
                  c1.parent_id,
                  c2.category_title ParentCategory,
                  CONCAT_WS(' -&gt; ', c2.category_title, c1.category_title) category_title
          FROM
              category c1
          left outer join category c2 ON c1.parent_id = c2.id WHERE c1.parent_id != 0
  </code></pre>
  
  <p>which return:</p>
  
  <p><img src="https://i.stack.imgur.com/IxZ9c.png" alt="enter image description here"></p>
  
  <p>I've read several times this <a href="https://stackoverflow.com/questions/4715677/difference-between-left-join-and-right-join-in-sql-server">answer</a> but I can not see why my right join isn't working.</p>
  
  <p>The first result set should have 8 more columns, the columns of categories which parent is <code>Protesta</code></p>
  
  <h1>UPDATE</h1>
  
  <p>I got it working whith the following query:</p>
  
  <pre><code>SELECT * FROM (SELECT
          i.id,
          incident_title 'Título',
          incident_description 'Descripción',
          incident_date 'Fecha',
          incident_active 'Aprobado',
          incident_verified 'Veficado',
          person_first 'Nombres',
          person_last 'Apellidos',
          person_email 'Email',
          category_id
          -- category_title 'Categoría',
          -- ParentCategory 'Categoría Padre'
      FROM
          incident i
              INNER JOIN
          incident_category ic ON i.id = ic.incident_id
              RIGHT JOIN
          incident_person ip ON i.id = ip.incident_id
  
      WHERE (incident_dateadd &gt; DATE_SUB(NOW(), INTERVAL 1 MONTH) OR incident_dateadd IS NULL)) a
  RIGHT JOIN
  
  (SELECT
              c1.id,
                  c1.parent_id,
                  c2.category_title ParentCategory,
                  CONCAT_WS(' -&gt; ', c2.category_title, c1.category_title) category_title
          FROM
              category c1
          left outer join category c2 ON c1.parent_id = c2.id WHERE c1.parent_id != 0) b ON a.category_id = b.id
  </code></pre>
  
  <p>Although I still don't understand why it was not working with the first version, in my mind both queries are equivalent.</p>
  
  <p>If anyone could explain the differences...</p>