Hi,
I need some direction on how to construct a where clause for a view. The goal is to select all rows containing a word or phrase no matter where in the field it is. I have hardcoded in the test example below a first name of "Albert" and last name is "Lykins"
Results from the searched field can contain "Albert Lykins", " Lykins, Albert", "William, John Lykins and Albert Lewis".
I did NOT wish to see "Alberta Lykins", "Lykins, Mary & Albertson"
Below is my test bench where I have tried many many variations and none is returning the expected results. So simple in fox...
Thanks, Stanley
I need some direction on how to construct a where clause for a view. The goal is to select all rows containing a word or phrase no matter where in the field it is. I have hardcoded in the test example below a first name of "Albert" and last name is "Lykins"
Results from the searched field can contain "Albert Lykins", " Lykins, Albert", "William, John Lykins and Albert Lewis".
I did NOT wish to see "Alberta Lykins", "Lykins, Mary & Albertson"
Below is my test bench where I have tried many many variations and none is returning the expected results. So simple in fox...
Thanks, Stanley
Code:
Set Ansi Off
Set Path To '.\, .\data, .\programs'
Open Database 'TestStatus'
Use In Select('rv_ML2')
If Indbc('rv_ML2', 'VIEW')
Delete View 'rv_ML2'
Endif
lcBase = [Create Sql View 'rv_ML2' Connection AppData ] + ;
[AS Select full_name, address1, county_name ]+ ;
[From dbo.MailingList MailingList WHERE ]
lcFirst = 'Albert'
lcLast = 'Lykins'
lcPhrase1 = lcFirst
lcPhrase1A = [] + lcFirst + [%]
lcPhrase2 = [%] + lcLast + [%]
lcWhere9 = [( MailingList.full_name Like ?lcPhrase1 or MailingList.full_name Like ?lcPhrase1A) ] && ;
+ [ and MailingList.full_name Like ?lcPhrase2 ]
lcCreateView = m.lcBase + m.lcWhere9
&lcCreateView
Use 'rv_ML2' In 0
Select 'rv_ML2'
Requery()
Go Top
Browse Last