Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wild card in where clause
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00246921
Message ID:
00246955
Views:
17
>Thanks for the info. The SQL like works fine.
>Are there any reasons to choose one over the other?
>

There are a couple of strong arguments regarding the use of the LIKE clause and LIKE() function. The obvious advantage to the LIKE clause is the portability of queries to database engines other than VFP's native engine. ANSI SQL supports the LIKE clause, while LIKE() is an internal VFP function. This simplifies the process of upsizing the engine at a later date. If you have a query that goes against a backend database at some point, the LIKE clause can be executed at the backend server, while if LIKE() can be used at all, it'll have to be processed at least in part by VFP's engine. Processing by a backend server can reduce network traffic, implement database features not available to the VFP native engine, and offer at the least possibility of significantly rescaling the database engine as needed.

The advantages of the LIKE() function are that most users are already familiar to some extent with the meaning of DOS wildcards, so it makes it easier for them to build the string on the fly that it can be combined with other VFP native functions easily, so some complex expressions that use other VFP native functions or UDFs, such as SUBSTR() or UPPER(), which would have to run on the VFP application engine IAC, could be combined easily into a single VFP expression - the LIKE clause doesn't have this option available to it, and if you use the LIKE clause in conjunction with UDFs or native functions, you give up the option of backend processing anyway.

>Also what would work for a logical field? I have a form property with a nValue of 0, 1 or 2 and I want to select on obsolete = .t., .f. or either.
>
>>>Can you use a wildcard in the where clause of a select statement?
>>>
>>>
>>>if thisform.cToShow = "All"
>>> lcCatToShow = "" &&>>> This is where I want a wildcard
>>
>>You can use wildcarding in at least two ways.
>>Standard DOS-style wildcarding (? matches any single character, * any number of characters) using the LIKE() function in your WHERE clause rather than equivalence; IOW, rather than CatLink.Catagory == lcCatToShow , you'd say LIKE(lcCatToShow,CatLink.Catergory,) .
>>
>>Alternatively, you can use the SQL LIKE Clause (% == *, _ == ?), so that instead of CatLink.Catagory == lcCatToShow you'd say CatLink.Category LIKE lcCatToShow.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform