title: Why Are table rows passed from main query to subquery, rather the whole table, in sql EXIST operator?
body: <p>I've been learning sql from w3school and got to the <a href="https://www.w3schools.com/sql/sql_exists.asp" rel="nofollow noreferrer"><code>EXIST</code> operator chapter</a>. I am also studying this <a href="https://stackoverflow.com/questions/5846882/how-do-sql-exists-statements-work">stackoverflow post</a>.</p>
  <p>The main example being used is this:</p>
  <pre><code>SELECT SupplierName
  FROM Suppliers
  WHERE EXISTS (SELECT ProductName FROM Products WHERE Products.SupplierID = Suppliers.supplierID AND Price &lt; 20);
  </code></pre>
  <p>I know that <code>WHERE</code> clause checks the condition for each row. Now if I run the subquery on it's own I'd get an error:</p>
  <pre><code>SELECT ProductName FROM Products WHERE Products.SupplierID = Suppliers.supplierID AND Price &lt; 20)  
  </code></pre>
  <p>Error: <code>Suppliers</code> is undefined.</p>
  <p>What I don't understand is why does the subquery use only one row from the <code>Suppliers</code> table from the main query? I know this must be true, because if the subquery uses the whole <code>Suppliers</code> table then it would return true always and we would display all suppliers, even the ones with <code>Price &gt; 20</code>.</p>
  <p>The linked <a href="https://stackoverflow.com/a/10379739/3429430">SO answer</a> also mentions this:</p>
  <blockquote>
  <p>The magic link between the outer query and the subquery lies in the fact that Supplier_id gets passed from the outer query to the subquery for each row evaluated.</p>
  </blockquote>
  <p>So, can someone direct me to an official reference for any sql language which mentions/explains that the subquery doesn't use the whole <code>Suppliers</code> table, but one particular row(the one being selected in the main query).</p>