Hi, How can I build an ORM query using the sql OVERLAPS operator?
The overlaps operator can be expressed with the query: """ SELECT * FROM PERIOD WHERE (P1_START > P2_START AND (P1_START < P2_FIN OR P1_FIN < P2_FIN)) OR (P2_START > P1_START AND (P2_START < P1_FIN OR P2_FIN < P1_FIN)) OR (P1_START = P2_START AND (P1_END IS NOT NULL AND P2_END IS NOT NULL)) """ The following query has the same result but is optimilized by the db engine: """ SELECT * FROM PERIOD WHERE (P1_START, P1_END) OVERLAPS (P2_START, P2_END); """ Thank lmg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---