Solved

String Search Vfoxpro forms

Posted on 2011-09-15
9
391 Views
Last Modified: 2012-06-27
Whenever I produce a form to, for instance, read customer data I've never solved the issue raised by some customers which is.
The user wants to search someone using his name, He doesn't know the complete name but he knows that his name is, at least John Smith. And the user also knows that the customer has some middle name.
Im my form he has to search for all the Johns in my database
But the customer would like John Smith and in the query would be returned all the persons that have John Smith in their name and, of course, John Doe Smith which is the person he's looking for.

How can I configure my search criteria in order to get a narrower search.
0
Comment
Question by:luciliacoelho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 27

Assisted Solution

by:CaptainCyril
CaptainCyril earned 250 total points
ID: 36541707
SELECT * FROM Client WHERE 'JOHN' $ UPPER(first+middle+last) AND 'SMITH' $ UPPER(first+middle+last)
0
 
LVL 42

Accepted Solution

by:
pcelba earned 250 total points
ID: 36541710
Many ways exist...

You may split the customer name into three fields: name, surname, and middlename. Then you may search based on text entered into these three fields. If some field remains empty then you have to remove it from the search criteria.

Slower options:
You may search each entered word by using GETWORDNUM() function.
You may use search based on a template using the LIKE SQL operator or LIKE() function.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 36541722
something like this (I did not test it)


cKeywords = "JOHN SMITH"
cString = " " + cKeywords + " "
cCriteria = ''
FOR i = 1 TO OCCURS(" ",cKeywords)+1
    cCriteria = cCriteria + IIF(i=1,'',' AND ') + '"' + STREXTRACT(cString, " ", " ", i) + '" $ UPPER(first+middle+last)'
ENDFOR

SELECT * FROM Client WHERE &cCriteria
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:jsrebnik
ID: 36548807
although all of the above suggestions will work, pcelba's suggestion about splitting the field into 3 fields and then indexing the fields would provide the fastest search option.  how large is the table?
0
 

Author Comment

by:luciliacoelho
ID: 36553302
Tables are not too big. i would say no more than 11 or 12 Mbytes

Best regards
0
 
LVL 2

Expert Comment

by:jsrebnik
ID: 36554198
I was more intersted in the number of records.  the larger the number of records, the more you'll benefit from indexing.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 36558497
I had these size of files containing memo fields and without indexing I managed to get all the searches very fast:

1) Case Search
2) Multiple keywords search
3) Exact sentence search
...
0
 

Author Comment

by:luciliacoelho
ID: 36590452
my tables do not have more than 70.000 records
0
 
LVL 42

Expert Comment

by:pcelba
ID: 36591898
Even 70.000 could be too many in some slow network environments. If you are searching 70.000 records in local data on a standalone computer with a few gigs of memory then it is OK.

Indexes and appropriate query parameters will always speed the processing up.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Insert into Excel a sum for three columns 8 693
Foxpro9 import of excel Table 4 615
How can i delete a , space in VFP9 4 104
Controlling printer trays from browser 3 202
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
By reading this blog, MSPs will gain insight into how to improve communications with their clients as well as establish a more profitable business.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question