Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

String Search Vfoxpro forms

Posted on 2011-09-15
9
Medium Priority
?
432 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 1000 total points
ID: 36541707
SELECT * FROM Client WHERE 'JOHN' $ UPPER(first+middle+last) AND 'SMITH' $ UPPER(first+middle+last)
0
 
LVL 43

Accepted Solution

by:
pcelba earned 1000 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
Independent Software Vendors: 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 43

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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

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…
This applies to Dell but may also apply to other manufacturers as well. We ran across a few machines that just dropped recently it trust relationship with the server. After doing the basic removing and joining the domain again, it changed to No logo…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

576 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