0

I have two models: Book and Author

Book table has author_id and cover_color. Author table has id(primary key) and name

I want to have all the books that are red and their author's name is "John". Is it possible using activejdbc (without raw query) in one query? If so, how?? If not, what is the best way to do it?

the SQL equivalent is:

SELECT * FROM Books INNER JOIN Authors ON Books.author_id=Authors.id WHERE Books.cover_color='red' AND Authors.name='John'

Thanks in advance

Feri
  • 1,071
  • 7
  • 19

1 Answers1

0

The methods find(...) and where(...) operate against the underlying table for a current model. Since you are collecting conditional data from more than one table, you will have to use a raw query similar to what you already have.

ipolevoy
  • 5,432
  • 2
  • 31
  • 46