Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using WHERE with wildcard specifications and LIKE
Message
From
26/04/2001 16:21:15
 
 
To
25/04/2001 14:12:36
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00499748
Message ID:
00500371
Views:
23
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
Previous
Reply
Map
View

Click here to load this message in the networking platform