How to join filling rows with null values in postgres
<p>In Postgres i have a table like this</p>

<pre><code>id  key value
1   first   x
1   second  y
1   third   z
1   fourth  k
2   first   o
2   second  p
2   third   q
</code></pre>

<p>The only possible values of column key are</p>

<pre><code>key
first
second
third
fourth
</code></pre>

<p>So this is my second table of interest.</p>

<p>I want to join this two tables adding a row with the same id and key but with null value when the starting table don't have all rows for the keys.</p>

<p>In fact the table that i want to get is this one</p>

<pre><code>id  key value
1   first   x
1   second  y
1   third   z
1   fourth  k
2   first   o
2   second  p
2   third   q
2   fourth  [null]
</code></pre>

<p>How can i do that in simple query? A simple right join is not useful since it do not add the null rows.</p>