Forum: Ruby on Rails Getting Distinct Rows While Still Returning Other Fields

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.
Ba79eb31ceaef95e9e52f5e5e4ec6d02?d=identicon&s=25 John Kopanas (Guest)
on 2007-03-11 16:27
(Received via mailing list)
On occasion I encounter this problem but I never remember how I fix it
the time before... which is annoying for myself.

I have the following find:
@conversations = Message.find(:all, :select => "DISTINCT from_user_id,
created_at", :conditions => ["to_user_id = ?", session[:user_id]])

I want distinct from_user_id but at the same time I want to have other
fields removed like created_at.  If I return more then from _user_id I
am not getting distinct from_user_ids...

What is the rails way of solving my problem? :-)

Thanks eveyone for helping me out! :-)
John Kopanas
This topic is locked and can not be replied to.