Is there a cleaner way to do the following?
friend_ids = [1,2,3,4,5]
friendIDsQuery = ""
friend_ids.each_with_index do |friend_id, index|
friendIDsQuery += "SELECT id FROM test WHERE user_id = #{friend_id}"
if index != friend_ids.size - 1
friendIDsQuery += " INTERSECT "
end
end
Basically I'm passing in an array of IDs, and building a custom INTERSECT query.