You can do this:
sql = "Select * from ... your sql query here"
records_array = ActiveRecord::Base.connection.execute(sql)
records_array
would then be the result of your sql query in an array which you can iterate through.
More Related Contents:
- PostgreSQL GROUP BY different from MySQL?
- MySQL not using indexes with WHERE IN clause?
- Best way to count rows by arbitrary time intervals
- Disable Rails SQL logging in console
- ActiveRecord Arel OR condition
- LEFT OUTER JOIN in Rails 4
- Rails 3 execute custom sql query without a model
- Perform this hours of operation query in PostgreSQL
- Join multiple tables with active records
- PostgreSQL where all in array
- SQL where joined set must contain all values but may contain more
- Find records where join doesn’t exist
- Rails 4 LIKE query – ActiveRecord adds quotes
- Find all records which have a count of an association greater than zero
- Rails find record with zero has_many records associated [duplicate]
- Prepared Statement on Postgresql in Rails
- ActiveRecord find_each combined with limit and order
- Sort by column ASC, but NULL values first?
- Using an Alias column in the where clause in Postgresql
- How to get next/previous record in MySQL?
- MIN/MAX vs ORDER BY and LIMIT
- Reference alias (calculated in SELECT) in WHERE clause
- SQL – Select first 10 rows only?
- SQL – Inserting a row and returning primary key
- How do I start auto increment from a specific point?
- How to use a dynamic parameter in a IN clause of a JPA named query?
- Perform regex (replace) in an SQL query
- How to export data from Excel spreadsheet to Sql Server 2008 table
- Query a Table’s Foreign Key relationships
- How to get the next number in a sequence