John Kopanas
2007-Mar-11 15:27 UTC
Getting Distinct Rows While Still Returning Other Fields
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 john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org http://www.kopanas.com http://www.cusec.net http://www.soen.info --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---