Skip to content

Instantly share code, notes, and snippets.

@tka
Last active August 29, 2015 14:02
Show Gist options
  • Save tka/26ffc91510b880f273a4 to your computer and use it in GitHub Desktop.
Save tka/26ffc91510b880f273a4 to your computer and use it in GitHub Desktop.
大概是這樣
sql = "select *, (select count(books.id) from books where books.authorsid=authors.id) as books_count from authors "
authors = Author.find_by_sql(sql)
authors.first.books_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment