title: How to use WHERE IN in Rails 3 project using MySQL 2?
body: <p>I am quite to new to Rails and have marginal experience with SQL-type languages.</p>
  
  <p>I am working on a Rails 3 project using a MySQL2</p>
  
  <p>I have here a generic SQL statement that I want to work on BOTH of our databases. Is there any way to do this through just the ActiveRecord functionality?</p>
  
  <pre><code>SELECT * FROM MyRecords 
  WHERE  (f1, f2, f3, f4) IN (
      SELECT f1, f2, f3, f4
      FROM   MyRecords
      GROUP  BY f1, f2, f3, f4
      HAVING count(*) = 1 
  );
  </code></pre>
  
  <p>In other words, I am trying to execute a "WHERE IN" statement (and to be frank, I don't even know what a WHERE IN statement does, just that this answer does what I need: How do I (or can I) SELECT DISTINCT on multiple columns (postgresql)? ) To be more specific, I have to augment the following ActiveRecord function so that it does the above query:</p>
  
  <pre><code>  def MyRecordFunction
      MyRecords.where('org_id=?', self.org_id).order('f4')
    end
  </code></pre>
  
  <p>Thank you.</p>