Hi people I want to know if you know how to write the following sql query in a more "rails way" UPDATE buy_order_detail SET saldo = saldo - detail_purchase.cantidad FROM purchase_detail INNER JOIN purchase ON purchase.id purchaser_detail.purchase_id INNER JOIN waybill ON waybill.id purchase.waybill_id INNER JOIN buy_order ON buy_order.id waybill.order_id INNER JOIN buy_order_detail ON buy_order.id buy_order_detail.order_id WHERE purchase_detail.product_id = buy_order_detail.product_id -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.