Can I ask if there is a good reason that you are doing it this way
rather the Rails way using associations? If you do not know then tell
us about the models and associations and what you are trying to
achieve with the query.
You can use select method to define selectable fields like Assignment.select(‘assignments., courses.’) but you’ll get the array of Assignment objects with course columns.