how to fire distinct query ?

i am having this code for record distinct but this code is not working
???

Dharmdip Rathod wrote:

i am having this code for record distinct but this code is not working
???

__________________________________________________________________________________

<%for postjob in @postjob = Postjob.find(:all)%>
###### This Line of code is not working ##########
<%@postjob = Postjob.find( :all, :select => 'DISTINCT country' )%>
####### This part is working ##########
<p style="margin-left: 50px ; color: red" ><%= link_to
"#{postjob.country}" , :controller => "", :action => "country_list" ,
:id => p%></p>
<%end%>
__________________________________________________________________________________

please help !

Just go with
<%for postjob in @postjob = Postjob.find(:all, :select => 'DISTINCT
country') %>
ba bye

<%for postjob in @postjob = Postjob.find(:all)%>

so at this point @postjob is an Array of your Postjobs

This Line of code is not working

<%@postjob = Postjob.find( :all, :select => ‘DISTINCT country’ )%>

and then here you’re re-assigning it something else.

####### This part is working ##########

<%= link_to

“#{postjob.country}” , :controller => “”, :action => “country_list” ,

:id => p%>

Where does p used in (:id => p) come from?

Maybe you can give more details about your Model and what
exactly you would like to present using this code.

Franz

hi,

U can also do like this,

@postjob= Postjob.find_by_sql("select distinct from postjobs")

thanks,
shripad