Forum: Ruby on Rails find_by_sql distinct

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Brutyn N. (Guest)
on 2005-12-13 10:45
(Received via mailing list)
hey,

i have this sql statement
@all_clients = Client.find_by_sql("select distinct * from clients
......")

is there any other way for implementing this "distinct" into an sql
statment
with parameters??

thanks in adavance
Nick
Damaris F. (Guest)
on 2008-01-10 17:01
Yes, with

@all_clients = Client.find(:all, :select => "DISTINCT x"

where x will be the column you want to discriminate with.


Brutyn N. wrote:
> hey,
>
> i have this sql statement
> @all_clients = Client.find_by_sql("select distinct * from clients
> ......")
>
> is there any other way for implementing this "distinct" into an sql
> statment
> with parameters??
>
> thanks in adavance
> Nick
This topic is locked and can not be replied to.