Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
= and == in SQL
Message
 
À
27/03/2002 08:39:29
Denis Filer
University of Oxford
Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00637774
Message ID:
00638128
Vues:
25
Denis,

This is related to how xBase compares strings, by default strings are compared until the string on the right of the comparison operator is exhausted and the result at that point is returned.

In VFP we can control this behavior using the SET EXACT and SET ANSI commands. SET EXACT works for Fox operations and SET ANSI works for SQL SELECT operations.

Both SET EXACT and SET ANSI work the same way, if they are OFF the comparison is to the end of the shorter string, if they are ON then the shorter string is padded with spaces to be equal in length to the longer string and then they are compared.

SET EXACT ON and SET ANSI ON are NOT the same as ==. == compares for exact equality. An example will illustrate the difference better than discussion.
SET EXACT ON
lcVar1 = "Jim"
lcVar2 = "Jimmy"
? lcVar2 = lcVar1  && .F.
? lcvar2 == lcvar1 && .F.
lcvar2 = "Jim   "
? lcVar2 = lcVar1  && .T. because the shorter is padded with spaces
? lcvar2 == lcvar1 && .F. because they are not the same length
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform