Microsoft Knowledge Base Email Alertz

KBAlertz.com: (98434) - To broaden the selections of a structured query language (SQL) statement, two wildcard characters, the percent sign (%) and the underscore (_), can be used. The percent sign is analogous to the asterisk (*) wildcard character used with MS-DOS. The...

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **


Community Site



We Send hundreds of thousands of emails using ASP.NET Email


ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 98434 - Last Review: February 12, 2007 - Revision: 3.4

How to use wildcard characters in the SQL-SELECT statement in Visual FoxPro

This article was previously published under Q98434

SUMMARY

To broaden the selections of a structured query language (SQL-SELECT) statement, two wildcard characters, the percent sign (%) and the underscore (_), can be used.

The percent sign is analogous to the asterisk (*) wildcard character used with MS-DOS. The percent sign allows for the substitution of one or more characters in a field.

The underscore is similar to the MS-DOS wildcard question mark character. The underscore allows for the substitution of a single character in an expression. Three examples showing the use of these characters in SQL-SELECT statements are provided below. The examples use the Customer.dbf file that is included with Microsoft Visual FoxPro in the Home(2)+data folder.

MORE INFORMATION

The following SELECT-SQL statement returns all the records from the Customer.dbf table that contain a "W" as the first character in the Regionabbreviation field. The SELECT-SQL statement lists the records from "WY" and "WA" in a Browse window.
   SELECT * from customer WHERE Region like "W_"
				
The following SELECT-SQL statement lists all the records that have a "P" or a "C" as the last character in the Regionabbreviation field. The output includes records from "SP" and "BC."
   SELECT * from customer WHERE Region like "_P" OR region like "_C"
				
The following SELECT-SQL statement uses the percent sign and the underscore to return all the records that have a Cust_ID that starts with "G" and that have a Regionabbreviation field that ends with "P."

Note The percent sign lets any string of characters follow the "G." Conversely, the underscore permits the substitution of only a single character.
 SELECT * FROM Customer WHERE cust_ID LIKE "G%"  AND region LIKE "_P"
				
To do a string search similar to the one performed by the $ function, use a statement like:
SELECT * from customer WHERE company like "%M%"
				
This SELECT-SQL statement finds all companies that have names that contain "M."

REFERENCES

For additional information, see the Visual FoxPro Help files. Search for "SELECT - SQL."

APPLIES TO
  • Microsoft Visual FoxPro 7.0 Professional Edition
  • Microsoft Visual FoxPro 8.0 Professional Edition
  • Microsoft Visual FoxPro 9.0 Professional Edition
Keywords: 
KB98434
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please