On Wednesday, 27 June 2012 10:13:16 UTC-4, amruby wrote:>
> i have one query
> @recommendations = Recommendation.select(''cnames.name
> ,max(recommendations.count)'').
> where(''recommendations.skill= ?'',@key).
> order(''recommendations.company_id
ASC'').
> group(''recommendations.company_id'').
> joins(''JOIN recommendations ON cnames.id =
> recommendations.company_id'')
>
> when i run this query i got this error
>
> *PG::Error: ERROR: table name "recommendations" specified more
than once*
>
> Why it shows like that?
>
Since you''re querying on the Recommendation model, there''s
already a ''FROM
recommendations'' clause in the generated query. You probably meant
''cnames''
in that joins call.
You''ll also run into Postgres''s rules about using ungrouped
values in the
SELECT part; the above query won''t be legal even with a correct join.
--Matt Jones
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/11kmrUtXqhQJ.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en-US.