JOIN the table if records exist
<p>is it possible if i want to do INNER JOIN only if the record exist on the 2nd table if not then dont join?</p>

<p>this is my table</p>

<p><strong>User</strong> table</p>

<pre><code>+--------+--------------+
|   id   |     name     | 
+--------+--------------+
|   1    | John         |
+--------+--------------+
|   2    | Josh         | 
+--------+--------------+
</code></pre>

<p><strong>House</strong> table</p>

<pre><code>+--------+-------------+--------------+ 
|   id   |   owner_id  |   house_no   |
+--------+-------------+--------------+
|   1    |      1      |      991     | 
+--------+-------------+--------------+
</code></pre>

<p>this is my INNER JOIN query</p>

<pre><code>SELECT h.owner_id, u.name, h.house_no FROM user u
INNER JOIN house h on u.id = h.owner_id 
WHERE u.id = :id
</code></pre>

<p>it will return this result if <code>id = 1</code></p>

<pre><code>+--------+--------------+--------------+ 
|   id   |     name     |   house_no   |
+--------+--------------+--------------+
|   1    | John         |      991     | 
+--------+--------------+--------------+
</code></pre>

<p>but if i run with <code>id = 2</code> no result returned.</p>

<p>what i want to do right now is it still return the result even when no data exist for <code>id = 2</code> in table house</p>