Solved

String Search Vfoxpro forms

Posted on 2011-09-15
9
341 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
  • 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 41

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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 41

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now