Ruby on Rails
Wednesday, August 24, 2016
This rails/sql code...
@new_relationships = User.select('*')
.from("(#{@rels_unordered.to_sql}) AS rels_unordered")
.joins("
INNER JOIN relationships
ON rels_unordered.id = relationships.character_id
ORDER BY relationships.created_at DESC
")
produces a query that begins like this:
SELECT COUNT(*) FROM (SELECT .....
Why is it counting the records?? I haven't asked for a count. I simply want to select all columns after the join:
SELECT * FROM (SELECT .....
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f3c5dbc2-b971-48c7-977d-39f79225151c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment