Re: Best approach?
- From: "Anders Altberg" <anders.altberg>
- Date: Mon, 17 Mar 2008 01:28:53 +0100
DIMENSION cArray (4,1)
cArray(1,1)='RED'
cArray(2,1)='PAINT'
cArray(3,1)='SPRAY'
cArray(4,1)='CAN'
CREATE CURSOR searchwords (word char(20))
INSERT INTO Searchwords FROM ARRAY cArray
CREATE CURSOR inventory (id Int, descript Memo)
INSERT INTO Inventory VALUES (1,'SPRAY HAIR BLUE')
INSERT INTO Inventory VALUES (2,'PAINT RED SPRAY')
INSERT INTO Inventory VALUES (3,'BLUE HAIR SHAMPOO')
SELECT COUNT(*),id,word, MAX(CAST(descript as char(40)))as descript ;
FROM inventory,Searchwords WHERE descript like '%'+TRIM(word)+'%' ;
GROUP BY id,word ;
INTO CURSOR Q1
SELECT SUM(cnt),id,descript FROM Q1 GROUP BY 2,3 INTO CURSOR Q3
BROWSE
Q3 shows that there were 1 hit in record #1, and 3 hits in record #2, for
the 4 searchwords.
-Anders
"John Germany" <jgphotography@xxxxxxxxxxxxxx> wrote in message
news:um9r0y6hIHA.2540@xxxxxxxxxxxxxxxxxxxxxxx
I've written a function that parses a search string and returns a 1D array
for each word in the string.
Such as, "PAINT SPRAY RED" would return an array of
cArray[1,1]="PAINT"
cArray[2,1]="SPRAY"
etc.
Now I want to issue a SELECT statement to search my inventory file
Select * from inventory WHERE cArray[1,1]$descript AND .... (or several
other fields may be searched) and so on...
The problem is that I can't hard code the select statement because the
function will create the number of elements for the array based on how
many search terms are entered. I'm assuming a user defined function in
the select to return the WHERE clause would work, but is this best? (or is
this even permissable and will a UDF in a Select statement return correct
results?)
What would be the best approach for this?
How do search engines like google parse the search string and then return
the results to a cursor?
Thanks,
John
I'm using VFP8SP1
id
.
- Follow-Ups:
- Re: Best approach?
- From: John Germany
- Re: Best approach?
- References:
- Best approach?
- From: John Germany
- Best approach?
- Prev by Date: Re: Best approach?
- Next by Date: Re: Insert sql ... if not found idea
- Previous by thread: Re: Best approach?
- Next by thread: Re: Best approach?
- Index(es):
Relevant Pages
|