Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
= and == in SQL
Message
 
À
27/03/2002 08:46:22
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
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:
00637803
Vues:
19
>>The SQL command: ... where alltrim(MYFIELD) = "VALUE" gives an erroneous result. The command: ... where alltrim(sp.MYFIELD) == "VALUE" is OK. The single = includes records with blank values. Why is this?
>
>See SET EXACT. == means "exactly equal".
>
>
>x = "abcde"
>y = "abc"
>set exact off
>? x = y  && returns .T. - comparison is done until the end of "y" is reached.
>
>
>Hilmar.

Just to add - this behaviour
...WHERE MYFIELD = "VALUE"...
is also convenient for parameterized SQL statements or views when you want to bring all records - you just specify "" as a parameter. The = and == behaviour in SQL is determined by SET ANSI command as SET EXACT has no effect on SQL statements. (I am sure Hilmar pointed to SET EXACT only as a source for behaviour explanation). I myself typically never use SET ANSI command, but rather specify = or == in SQL statements.
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform