Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Difference between IN and $ in Views/SQL
Message
De
01/03/2005 21:57:39
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
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows 2000 SP4
Network:
Windows NT
Database:
Visual FoxPro
Divers
Thread ID:
00991852
Message ID:
00991854
Vues:
15
>Am I correct in assuming that the proper, and only way, to search for a string CONTAINED within a given field is to use the CONTAINS operator within my SQL statement like this:
>
>SELECT * FROM nameplat WHERE ALLTRIM(UPPER(lcSearchString)) $ (field_searched).
>
>And does "field_searched" have to be an actual fieldname, or can it be a variable that is used to reference any of several fields that the user can choose from.
>
>I am trying to give the user the ability to do "fuzzy searches" on a few select fields.
>
>Thank You.

You can place any valid logical expression after the WHERE clause. The exception is a few cases where VFP gets confused by similar commands, notably things like min(a, b) and max(a, b) (this conflicts with the min(FieldName) and max(FieldName), used in the GROUP BY clause).

In other words, to search on any field, I think you should be able to store the field name in a variable, call it lcFieldName, the value to be searched in another variable, lcValue, and then:
...WHERE &lcFieldName = lcValue
Conventional wisdom is that a name expression is faster than macro substitution, but I think that in this case, the macro substitution will be much faster, since the command is generated only once, and then executed for all the records.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform