Solved

String Search Vfoxpro forms

Posted on 2011-09-15
9
366 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Not enough memory to complete this operation 19 1,704
Save Table Settings 6 263
SQL Server CE 2.0 databases on desktop using ADO / OLE DB / VFP 8 58
Foxpro 64bit decoding 8 169
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…
When you’re making plans to join the modern business race, you should analyze various details that may affect your results. Nowadays, millions of businesses are trying to grow into established and appreciated professional enterprises.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 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