Forum: Ruby Question about using DISTINCT in ActiveRecord find method.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3320715fa6264e6309503d5bd089fad2?d=identicon&s=25 Mufaddal Khumri (mkhumri)
on 2006-01-12 18:48

Am relatively new to the RoR world. My question is quite simple.

I have a query like such:

shipmentNumbers = Order.find_by_sql(["select distinct from orders
o, line_items li, shipment_lines sl, shipments s where o.number=? and = li.order_id and = sl.line_item_id and sl.shipment_id =", number])

The above query works fine. I wanted to do the same query using the
query below:

shipmentNumbers = Order.find(:all,	 								 :conditions => ["number =
?", number],	 						 :joins => "as o join line_items as li on =
li.order_id join shipment_lines as sl on sl.line_item_id = join
shipments as s on sl.shipment_id =")

In the above query I need to add the "distinct" equivalent for
getting the correct results. Does anybody have an idea as to how I would
use the DISTINCT clause in the find(..) method?

31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-01-12 19:44
(Received via mailing list)
On 12/01/06, Mufaddal Khumri <> wrote:
> Am relatively new to the RoR world. My question is quite simple.

You'll probably get a faster answer on this from:

This topic is locked and can not be replied to.