How to get results from join only if all records match
<p>I am having a problem to make an SQL query. I have two tables named <code>'loans'</code> and <code>'loan_emilists'</code></p>

<p><a href="https://i.stack.imgur.com/ubhPy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ubhPy.png" alt="loan table"></a></p>

<p><a href="https://i.stack.imgur.com/QQQUz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QQQUz.png" alt="loan_emitlist table"></a></p>

<p>I want to fetch loan id from first table i.e 'loans' where loan.emilists table status have all 1.</p>

<p><strong>For example:-</strong> </p>

<p>Loan id = 1 Because in the 2nd table i.e. 'loan_emilists' loan_id = 1 have all status value 1.</p>

<p><strong>MySQL Query:-</strong></p>

<blockquote>
  <p>SELECT DISTINCT(loans.id) FROM <code>loans</code> LEFT JOIN loan_emilists ON
  loans.id = loan_emilists.loan_id WHERE loan_emilists.status = 1</p>
</blockquote>

<p>But it gives me both 1 and 2 loan.id.</p>