title: SQL Using Between for two tables
body: <p>Hi I want to fetch data from a Table based on values that lie between two columns of another table, below SQL shoulde explain my purpose:</p>
  
  <pre><code>SELECT * FROM TABLE 1 WHERE 1.FIELD1 BETWEEN 
  (SELECT 2.RANGE_FROM FROM TABLE 2) AND (SELECT 2.RANGE_TO FROM TABLE 2)
  </code></pre>
  
  <p>This is not working as I am getting error:</p>
  
  <pre><code>Error: SQL0811N  The result of a scalar fullselect, SELECT INTO statement, or VALUES INTO statement is more than one row.  SQLSTATE=21000
   (State:21000, Native Code: FFFFFCD5)
  </code></pre>
  
  <p>This is obvious as both the subqueries return multiple rows. So I want to write a SQL to perform above function without error.
  The platform is <code>IBM DB2</code>.</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Ok I think I solved this one by joining 2 tables using the condition:</p>
  
  <pre><code>SELECT * FROM TABLE1 A, TABLE2 B WHERE A.FIELD1 BETWEEN B.RANGE_FROM AND B.RANGE_TO
  </code></pre>
  
  <p>More testing is required though.</p>