title: Write SQL query and get values for given range using <= (or) between and (or) any other
body: <pre><code>create table demo4 
  (
      sno int, 
      fromvalue int, 
      tovalue int
  )
  
  insert into demo4 
  values (1, 2002, 2002), (2, 2003, 2003), (3, 2004, 2004), (4, 2001, 2010),
         (5, 2006, 2007), (6, 2011, 2011), (7, 2005, 2005), (8, 2006, 2010),
         (9, 2006, 2011), (10, 2008, 2009)
  
  
              |sno   |fromvalue |tovalue|
              +------+----------+-------+
              |  1   | 2002     |  2002 |
              |  2   | 2003     |  2003 |
              |  3   | 2004     |  2004 |
              |  4   | 2001     |  2010 |
              |  5   | 2006     |  2007 |
              |  6   | 2011     |  2011 |
              |  7   | 2005     |  2005 |
              |  8   | 2006     |  2010 |
              |  9   | 2006     |  2011 |
              | 10   | 2008     |  2009 |
  </code></pre>
  <p>From above table, I want to get <code>sno</code> values as 1,2,3,4 for given range 2002-2004 as from value and tovalue</p>
  <p>I tried with following queries, but it doesn't work</p>
  <pre><code>select * 
  from demo2 
  where (fromvalue between 2002 and 2004) 
     or (tovalue between 2002 and 2004)   
  
  -- 1, 2, 3 are fetched (4 is not fetched)
  
  select * 
  from demo2 
  where 2002 &lt;= fromvalue 
    and tovalue &lt;= 2004 
  
  -- 1, 2, 3 are fetched (4 is not fetched)
  </code></pre>