Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimize a where Sql clause
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01165268
Message ID:
01165272
Views:
15
This message has been marked as the solution to the initial question of the thread.
>Hello,
>
>Is it possible to optimize this sql clause ?
>Thank you in advance.
>
>bernhart
>
>
>
> WHERE  IIF( ?vp_sommeil = .T. , .T. , Employee.lsommeil = ?vp_sommeil )  AND ;
>  IIF( EMPTY( ?Vp_debut ) , IIF( EMPTY( ?Vp_nom ) , .T. , TELEPH.Cnomteleph  = ?Vp_nom ) AND  ;
>  IIF( ?Vp_lpresent  =  .T. , EMPTY( Employee.Dsortie ) , .T. ) , BETW( Employee.Dentree , ?Vp_debut , ?Vp_Fin )= .T.  OR  ;
>  BETW( Employee.Dsortie , ?Vp_debut , ?Vp_Fin )= .T.  OR  ( EMPTY( Employee.Dsortie ) AND Employee.Dentree < ?Vp_debut ) OR ;
>  (  Employee.Dsortie > ?Vp_Fin  AND Employee.Dentree < ?Vp_debut ) )    ;
>  GROUP BY  Employee.Iid   ORDER BY  Employee.Iid
>
try:
WHERE  ( ?vp_sommeil OR Employee.lsommeil = ?vp_sommeil )  AND ;
     IIF(EMPTY( ?Vp_debut ) ,;
        (EMPTY( ?Vp_nom ) OR TELEPH.Cnomteleph  = ?Vp_nom ) AND  ( NOT ?Vp_lpresent OR EMPTY( Employee.Dsortie )),;
         BETWEEN( Employee.Dentree , ?Vp_debut , ?Vp_Fin ) OR  ;
         BETWEEN( Employee.Dsortie , ?Vp_debut , ?Vp_Fin ) OR ;
        (EMPTY( Employee.Dsortie ) AND Employee.Dentree < ?Vp_debut) OR ;
        (Employee.Dsortie > ?Vp_Fin  AND Employee.Dentree < ?Vp_debut));
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform