Left outer join condition

Hi,

I am wondering what’s the best way to achieve this query:
select * from A left outer join B where B.a_id = A.id and
B.some_other_field = random_value where A.id = 12

Notice this is different from select * from A left outer join B on
B.a_id = A.id where A.id = 12 and B.some_other_field = random_value

While the second query can be easily achieved using includes, I didn’t
find any good way to issue first query

I will appreciate any help.

Regards,

On Jul 20, 6:45pm, Ritesh [email protected] wrote:

find any good way to issue first query

I think you just have to compose the join yourself - A.joins("left
outer join B on …).where(‘A.id = ?’, 12)

Fred

This seems to be a common problem. I am surprised that there is not
rails way to do this.

Ritesh

On Jul 21, 1:58am, Frederick C. [email protected]