title: postgresql rails price range filter with between
body: <p>I have the following array of price ranges how can I perform a query to find the price range between these using and operator</p>
  
  <p>This is the array I have </p>
  
  <pre><code>["0-1000", "5001_15000", "15001_25000"]
  </code></pre>
  
  <p>Whether this is the only way I have to perform else is ther any methods to perform such filter</p>
  
  <pre><code>select * from posts where price between 0 and 1000 and price between 5001 and 15000
  </code></pre>
  
  <p><strong>Edit-1</strong></p>
  
  <p>As your said I tried in my console</p>
  
  <pre><code>a = [[0,1000],[5001 ,15000], [15001, 25000]]
  
  (a[0].first..a[0].last)
  </code></pre>
  
  <p>This gives <code>0..1000</code> and when I try</p>
  
  <pre><code>(a[0].first..a[0].last and a[1].first..a[1].last)
  </code></pre>
  
  <p>It shows only <code>5001..15000</code> can you explain it please.</p>
  
  <p><strong>Edit-2</strong></p>
  
  <p>Only this works how can I add more values</p>
  
  <pre><code>Post.where(price: a[0].first..a[0].last)
  </code></pre>