Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A database challenge
Message
De
28/02/2008 06:05:21
Walter Meester
HoogkarspelPays-Bas
 
 
À
27/02/2008 14:26:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01295541
Message ID:
01297308
Vues:
30
>Doing a CASE WHEN in a where clause smells like amatuerism.

First of all, "Smells"....

>Ouch....you might want to re-think that one.

>If that indeed is true, then we have an awful lot of SQL authors, MVPs, and the good Lord J.C. himself (Celko) who would fall into that (all have printed queries that use it....it was about 6 years ago when I starting seeing a lot of it in print)

The WHERE clause takes a boolean expression... there should not be anything that cannot be expressed with AND and OR. Sometimes it might be easier or neccesarry to have a CASE WHEN in an argument of the expression e.g (CASE WHEN x THEN Field1 WHEN y FIELD2 ELSE Field3 END > aValue) but never *be* the boolean expression (as you did). On the average one should avoid them. . The reasoning behindit is:

- Any Boolean logic expression can be descibed with AND and OR
- Developers are used to think in terms of AND and OR.
- CASE WHEN expressions are not optimizable.

Please give me an example of those SQL authors who do advocate using them in WHERE clauses. Also I don't have an high opinion per se on any MVP in this regards. MVP does not stand for any level of quality.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform