Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using WHERE with wildcard specifications and LIKE
Message
De
26/04/2001 16:21:15
 
 
À
25/04/2001 14:12:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00499748
Message ID:
00500371
Vues:
20
Pessy,

I've found the LIKE operator somewhat complex to work with, as well as concatenated fields in SQL statements. The KISS principle works well here!

An alternative approach, if you need flexibility in creating SQL statements, is to create the clause you need in a string, then use macro substitution in the SQL statement. Because the macro substitution is performed only once, there's little performance penalty. And, this approach can be generalized to other SQL clauses.

For example:
lcWhereClause = "WHERE cField1 = 'AJ'"     && for a literal value
SELECT (fields) ;
    FROM (tables) ;
    &lcWhereClause ;
    INTO (output)

*   Here are some alternative formulations
lcWhereClause = "WHERE cField1 = cInScopeVariable"
lcWhereClause = "WHERE cField1 = " + "'" + cToInsertALiteralValue + "'"
lcWhereClause = "WHERE nField1 = 1"
lcWhereClause = "WHERE nField1 = nInScopeVariable"
lcWhereClause = "WHERE nField1 = " + TRANSFORM (nToInsertALiteralValue)
Jay
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform