On Oct 11, 5:48 am, Christer Nilsson <[email protected]>
wrote:
> Thanks for your interesting answers.
>
> I'm sorry for not expressing myself clearly enough.
>
> I need "join between databases" and "order by".
>
> Better example:
>
> Give me the list of all pets ordererd by their owners name.
>
> SELECT B.Pets.Name, A.Humans.Name
> FROM B.Pets
> JOIN A.Humans ON B.Pets.Owner_ID=A.Humans.ID
> ORDER BY A.Humans.Name
>
> Is this possible to express in Models, as Gavin did?
>
> class Human < Sequel::Model(A[:humans])
>    one_to_many :pets, :key=>:owner_id
> end
> class Pet < Sequel::Model(B[:pets])
>    many_to_one :owner, :class=>:Human, :key=>:owner_id
> end
>
> Or does "join" imply abandoning Models altogether?

If you want this done in a single SQL query, it's going to require
database support for interdatabase queries, and will use the first
dataset in my earlier message.  The only other way to do it is to make
two queries and stitch the results together manually.

Does the SQL you provided work on your database?

For one_to_many and many_to_one associations, it doesn't matter unless
you want to use eager_graph, as both lazy loading and eager loading
via eager are going to work by default with models from separate
databases.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to