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.
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 Brutyn Nick (Guest)
on 2005-12-13 09: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
28a4d1b683ec25e1d0312a2a90f63b6f?d=identicon&s=25 Damaris Fuentes (damaris)
on 2008-01-10 16:01
Yes, with

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

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


Brutyn Nick 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.