title: retrieve records between fromdate and todate passing two dates and foreign key value in MYSQL or HQL
body: <p>retrieve records  between fromdate and todate passing two date and foreign key value.
   <img src="https://i.stack.imgur.com/VGKR7.png" alt="enter image description here"></p>
  
  <p>i tried this,</p>
  
  <pre><code>SELECT* FROM Test where T_ID = 1 and '2015-03-10' BETWEEN FROM_DATE and TO_DATE or '2015-03-18' BETWEEN FROM_DATE and TO_DATE;
  </code></pre>
  
  <p>but it returns  foreign key records with another foreign key records between these dates </p>
  
  <p>the correct result size should be 2. 
  but here returns 4.</p>