Hello,

Need to realize in ORM manner the next SQL query:
SELECT p.*
FROM person p
JOIN person cl
ON p.left_key > cl.left_key AND p.right_key < cl.right_key WHERE cl.id=3;

I've tried to do this using block:
Person.where(:person__id => 3).join(Sequel.as(:person, :cl)) do |p, cl, js| 
    (Sequel.qualify(p, :left_key) > Sequel.qualify(cl, :left_key) and 
Sequel.qualify(p, :right_key) < Sequel.qualify(cl, :right_key)) 
end

But no success, only the last condition is observed in the result sql:
SELECT * FROM "person" INNER JOIN "person" AS "cl" ON ("cl"."right_key" < 
"person"."right_key") WHERE ("person"."id" = 3)

How can I use multiple such comparative conditions?

Thanks in advance.

-- 
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to