Re: [Rails-core] SQL query problem

1 view
Skip to first unread message
Message has been deleted

Jason King

unread,
Dec 18, 2009, 1:25:58 AM12/18/09
to rubyonra...@googlegroups.com
This is not an issue for the -core list - please restrict your user questions to the -talk list.

On Dec 17, 2009, at 9:10 PM, Ease Bus wrote:

> Please help me with finding a SQL select statement for the following
> problems.
>
> I have two classes: Site and Link
>
> Table Link has two columns: linking_site_id, and linked_site_id
>
> I would like to find all the links in table Link where linking_site_id
> = 3 or linked_site_id = 3 but only include a link where linked_site_id
> = 3 if the linking_site_id in that link is not one of the
> linked_site_id that site 3 links to. For example, if the Link table
> contains the following rows
>
> Linking_site Linked_site
> 2 1
> 3 2
> 3 4
> 5 3
> 2 3
>
> What SQL select statement would return only the following:
>
> 3 2
> 3 4
> 5 3
>
> If SQL query alone cannot do this, what is the most efficient way to
> do it via RoR? Thanks.
>
> Thanks.
>
> --
>
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages