2

ActiveRecordでこれをどのように書くべきですか?

select stores.id, stores.name, store_specials.active 
from stores 
left outer join store_specials on 
     (store_specials.store_id = stores.id and store_specials.special_id = 1) 
where stores.active = true;

ありがとう

4

1 に答える 1

2

Rails 3.x

Stores.select("stores.id, stores.name, store_specials.active").joins("LEFT OUTER JOIN tore_specials ON store_specials.store_id = stores.id AND store_specials.special_id = 1).where("store_specials.active = true")

うまくいけば、これはあなたが必要なものです

于 2012-04-26T16:52:14.203 に答える