title: Putting array in WHERE IN clause Ruby on Rails
body: <p>I'm building a ruby on rails application that uses raw SQL to query my database because I heard that it performs better than using ActiveRecord. I have an array that stores a list of items that are BigInts. For example:</p>
  
  <pre><code>my_items_id = [43627164222, 43667161211, 43667161000]
  </code></pre>
  
  <p>And my sql statement is supposed to return all values from a table where the id is any of the ones in <code>my_items_id</code>.</p>
  
  <pre><code>sql = "select * from table1 where id IN #{my_items_id}"
  records_array = ActiveRecord::Base.connection.execute(sql)
  </code></pre>
  
  <p>The reason why this doesn't work is because my_items_id is an array and i know that. But what is the best way to convert it to: <code>(43627164222, 43667161211, 43667161000)</code> so that the sql statement actually works.</p>