title: SQL - Select from table, if user_id is 0 select from different table
body: <p>I'm currently struggling with a SQL query, I have 2 tables, <code>clients</code> and <code>clientbook</code>.</p>
  <hr />
  <h2>The context</h2>
  <p><code>clientbook</code> is the table where <strong>there will always be a client entry</strong>:</p>
  <pre><code>id | firstname | lastname | user_id | saloon_id
  -----------------------------------------------
  1    lorem       ipsum      5         10
  2    jack        inthebox   0         10
  </code></pre>
  <p><code>clients</code> may or may not have an entry, based on if the client was logged in or not at the time of reservation. If <code>clientbook.user_id</code> is 0, the client won't be in <code>clients</code> table. <code>clients</code> looks like this:</p>
  <pre><code>user_id | firstname | lastname
  ------------------------------
  5         lorem       ipsum   
  </code></pre>
  <hr />
  <h3>The question</h3>
  <p>I want to make the following query:</p>
  <p>If <code>clientbook.user_id</code> is not <code>0</code>, then query <code>clients</code> and select the <code>clients.firstname</code> and <code>clients.lastname</code> from there.</p>
  <p>If <code>clientbook.user_id</code> is <code>0</code>, select the <code>clientbook.firstname</code> and <code>clientbook.lastname</code>.</p>
  <hr />
  <h2>What I currently have</h2>
  <p>I have this query:</p>
  <pre><code>    SELECT 
          c.firstname,
          c.lastname
      FROM
          clients AS c
      INNER JOIN
          clientbook AS cb
      ON
          c.id = cb.user_id
      WHERE
          c.firstname LIKE CONCAT(&quot;%&quot;, 'lorem', &quot;%&quot;)
      AND
          cb.saloon_id = 10
  </code></pre>
  <p>However, this will only select from <code>clients</code> if there is a row present. If no row exists, it will not select from <code>clientbook</code>.</p>
  <p>How can I make this query?</p>