On Friday, June 22, 2018 at 6:38:11 AM UTC-7, craig buchanan wrote:
>
> I have three models:
>
> class Opportunity < Sequel::Model
>   many_to_one :client
>   many_to_one :agent
> end
>
> class Client < Entity
>   one_to_many :opportunities
>
>   def self.my
>     # TODO: correlate
>     self.where{Opportunity.association_join(:client_entity).select(1)}
>   end
>
> end
>
> class Agent < Entity
>   one_to_many :opportunities
>
>   def self.my
>     # TODO: correlate
>     self.where{Opportunity.association_join(:recruiter_entity).select(1)}
>   end
>
> end
>
>
> I'd like to create a correlated, sub-query to get a unique list of each 
> Client and Agent using the `my` method.  What's the syntax to correlate the 
> sub-queries?
>
> I suppose I could use an association join with a DISTINCT, but I can see 
> the sub-query being useful, so I'd like to understand its syntax.
>

Please post the SQL you want to generate, then I can show how to express it 
with Sequel.

Thanks,
Jeremy 

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to