Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching for a partial string
Message
From
01/06/2002 13:10:55
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00663531
Message ID:
00663798
Views:
11
Here is a solution that is based on the concept of a suffix array.

Assuming two tables with the following structures:
CREATE TABLE Master ;
    (Pkey I PRIMARY KEY, ;
    Skey c(10) CHECK Master_Skey_Validator())
CREATE TABLE Suffix ;
    (Skey c(10), ;
    Pkey I, ;
    FOREIGN KEY Pkey TAG Pkey REFERENCES test1)
INDEX ON skey TAG skey
With Master_Skey_Validator() in the database as a stored procedure:
FUNCTION Master_Skey_Validator
	LOCAL lnPrimaryKey, lcSearchKey, i
	lnPrimaryKey = Master.Pkey
	DELETE FROM Suffix WHERE pkey = lnPrimaryKey
	lcSearchKey = ALLTRIM(Master.Skey)
	FOR i = 1 TO LEN(lcSearchKey)
		INSERT INTO Suffix (Pkey, Skey) ;
			VALUES (lnPrimaryKey, SUBSTR(lcSearchKey, i))
	ENDFOR
ENDFUNC
You can search with this select:
SELECT DISTINCT Master.* ;
    FROM Master INNER JOIN Suffix ON Master.Pkey = Suffix.Pkey ;
    WHERE Suffix.skey = "4-5"
Previous
Reply
Map
View

Click here to load this message in the networking platform