How to Create an Index on Part of a Character FieldID: Q98445 2.00 2.50 2.50a | 2.50 2.50a 3.00 kbprg
The information in this article applies to:
If you want to create an index on part of a character field, you can create the index with the SUBSTR() function. The following code is used for indexing on the first five characters of a field called NAME:
If the NAME field contains a last name and first name separated by a comma,
indexing on the last name can be performed as follows:
However, if the above command is used, FoxPro will create an index tag that
does not order the database accordingly. For example, with the NAME field
in a five-record database as listed below
using the INDEX statement above will result in the database being ordered
as follows:
To have the database ordered accordingly, you must use the PADR() function
to pad the string returned by the SUBSTR() function with spaces equal to
the length of the field. For example:
For more information, see the "Commands & Functions" manual for FoxPro
version 2.0 or the "Language Reference" manual for FoxPro version 2.5.
Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a string KBCategory: kbprg KBSubcategory: FxprgGeneral
|
Last Reviewed: April 30, 1996 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |