On Thursday, September 20, 2012 4:10:38 PM UTC-7, desbest wrote:
>
>
> <https://lh3.googleusercontent.com/-HxosViCEKP0/UFube_sMzeI/AAAAAAAAAZ8/UtVTCiWO7AQ/s1600/how+to+join.png>
>
>
> *When I use*
>
>> Post.where(:debate_id => view, :nodeview => 'status', :floor =>
>> 0).join(:votes, :id=>:nodeview_id).join(:votes, :debate_id)
>>
> I get this error.
>
>> SQLite3::SQLException: ambiguous column name: debate_id
>
>
You get this because, surprise surpise, the column name is ambiguous. Does
it refer to the column in the posts table or the column in the votes table?
Not to mention you appear to be joining to the votes table twice without
aliasing it.
>
> *When I use *
>
>> @approval = Vote.where(:nodeview => 'debate', :content =>
>> 'accept').join(:debates, :id=>:nodeview_id)
>>
>
> I have #{@approval[:content]} coming up blank, and #{@approval[:id]} being
> ambiguous.
>
The id column is probably in both tables. You need to disambiguate it,
probably by aliasing the column in SELECT.
> Please help!
>
Please post your database schema and describe the results you want. It's
clear that your current code is wrong, but I'm not even sure what code
would be right, since I don't know what you want.
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/cTb23y1RqasJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.