title: Select Extensions that the user is not subscribed to already
body: <p>I've been searching for a solution for my problem on Stack Overflow but I can't seem to find a solution that fits, or that I'm able to implement.</p>
  <p>I have three tables: &quot;Extensions&quot;, &quot;Subscriptions&quot;, &quot;Accounts&quot;.</p>
  <p>Extensions table:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>extension_id</th>
  <th>extension_name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>First Ext</td>
  </tr>
  <tr>
  <td>2</td>
  <td>Second Ext</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Subscriptions table:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>subscription_id</th>
  <th>extension</th>
  <th>user</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>1</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Accounts table:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>username</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>John</td>
  </tr>
  <tr>
  <td>2</td>
  <td>Sara</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Here there are two extensions with ID one and two, and user with ID one is subscribed to both in the subscriptions table.</p>
  <p>I have been successful in getting a list of the extensions the signed in user is subscribed to by doing:</p>
  <pre><code>SELECT 
      * 
  FROM 
      codium.extensions 
  JOIN 
      codium.subscriptions 
  JOIN 
      codium.accounts
  WHERE 
      extensions.extension_id = subscriptions.extension 
  AND 
      accounts.id = subscriptions.user 
  AND 
      accounts.id = :id 
  </code></pre>
  <p>Then in php define what :id is with <code>$sql-&gt;execute([&quot;id&quot; =&gt; $_SESSION[&quot;user_id&quot;]]);</code>.</p>
  <p>However, I have been unsuccessful in showing a list of subscriptions the user is <strong>not</strong> subscribed to. If the user is subscribed to just the first extension, show the second. If the user is subscribed to none at all, show both extensions.</p>
  <p>If it matters, when the query is executed, I use <code>$extensions = $sql-&gt;fetchAll();</code>, then foreach to echo a list.</p>
  <p>I've been at this problem for a long time, using Google and logic as my friend, but I can't seem to make it work. Either none shows, or I get the correct result in very specific circumstances, i.e. if the user is just subscribed to one extension.</p>
  <p>Appreciate all possible help.</p>