Indexing on a Character and Numeric Field TogetherID: Q115426 2.50x 2.6x 3.00 | 2.00 2.5x 2.6x | 2.5x 2.60a kbprg
The information in this article applies to:
SUMMARYIt is sometimes desirable to create an index on combined fields. Doing this becomes more difficult when one of the fields is numeric, and may contain negative numbers. The following example shows how this may be accomplished.
MORE INFORMATIONNOTE: This can also be accomplished by using the SQL SELECT command with its ORDER clause. The following table is in physical order. The CHAR field is a character field with a length of 10, and the NUM field is a numeric field with a width of 5.
The difficulty here is how to index on a string negative number. In a
character-based ascending index scheme, -004 doesn't come before -003.
FoxPro orders the data using the ASCII equivalents. To have the numbers
appear in ascending order, the numeric value must first be added to the
largest possible value for that field (99999 in this example) and then
converted to a string. For example, the following INDEX command creates a
compound index named COMBO that is in ascending order when the numeric
field is five spaces wide:
The following table contains the same data as above. However, it is now
in ascending order based on the COMBO index:
Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a
2.50b 2.50c 2.60 2.60a sort alphabetical combination
KBCategory: kbprg
KBSubcategory: FxprgGeneral
|
Last Reviewed: May 1, 1996 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |