Link to home
Start Free TrialLog in
Avatar of svfafel
svfafel

asked on

"ALL" keyword in WHERE clause

Is "All" a keyword in SQL?  I have this WHERE clause:

SELECT T1."Descr" c1, T2."ITMSCP" c2, T2."ITMITM" c3, T2."ITMCBL" c4, T2."ITMSTS" c5, T2."ITMTYP" c6, T2."ITMNME" c7, T2."ITMCRD" c8, T2."ITMPHN" c9, T2."ITMEML" c10, T2."ITMDTE" c11, T2."ITMEDT" c12, T3."ALSCDE" c13, T4."ICTNME" c14, T4."ICTCOD" c15

FROM "ACCOUNT" T1, "KITTRAK"."dbo"."ICTMST1" T4, ("ITMMST1" T2 LEFT OUTER JOIN "dbo"."ALSMST1" T3 on T2."ITMCMP"=T3."ALSCMP" and T2."ITMITM"=T3."ALSITM")

WHERE T2."ITMCMP"=T1."AccountID" and T2."ITMCAT"=T4."ICTCOD" and ('All'=lower ('all') or T2."ITMITM" like 'All%') and T2."ITMSCP" in ('LAN') and T2."ITMEDT">=20010101 and T2."ITMEDT"<=20011231 and T2."ITMCAT" in ('D')

ORDER BY 2 asc, 14 asc, 3 asc, 13 asc


Any ideas?  Can't seem to understand.
ASKER CERTIFIED SOLUTION
Avatar of Brendt Hess
Brendt Hess
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ibro
ibro

Agree with bhess1 - your condition ['All'=lower('all') will never be true. You can also optimize some clause in the where clause, so you query can run faster:
T2."ITMCAT" in ('D') will run faster if it written as
T2."ITMCAT"='D'
The same is valid for:
T2."ITMEDT">=20010101 and T2."ITMEDT"<=20011231
It will become:
T2."ITMEDT" between 20010101 and 20011231







Avatar of svfafel

ASKER

Thanks...much appreciated!!!