title: Search a table for two matching values using a hash in Ruby on Rails
body: <p>I have the following hash</p>
  
  <pre><code>{ "1" =&gt; "a", "2" =&gt; "a", "3" =&gt; "2"}
  </code></pre>
  
  <p>and the following sqlite3 table named ITEMS:</p>
  
  <pre><code>POSITION   CODE   NAME    VALUE
  "1"        "a"    "Cat"   "Small"
  "1"        "b"    "Cat"   "Big"
  "2"        "a"    "Fish"  "Red"
  "2"        "b"    "Fish"  "Blue"
  "3"        "1"    "Car"   "Fast"
  "3"        "2"    "Car"   "Slow"
  </code></pre>
  
  <p>I would like to query the table and return a hash of format {"NAME" => "VALUE"}.  </p>
  
  <p>The input hash is in the format {"POSITION" => "CODE"}, so the first value in the hash above has position "1" with code "a", which would return Name "Cat" and Value "Small".  The real version of this will have an initial hash of 20 values, and a table with closer to 200 records.</p>
  
  <p>The example hash above should return:</p>
  
  <pre><code>{ "Cat" =&gt; "Small", "Fish" =&gt; "Red", "Car" =&gt; "Slow" }  
  </code></pre>