jamie61880
2009-03-12 18:48:29 UTC
Hey everyone,
Does anyone know how to be able to search on all 3 fields for a First
Name, Middle Name, and a Last Name all in the same search box? I am able to do
this now, but the problem is if there are 2 words in a last name, such as "La
Rue", the search can't find this. The only way I know how to make this work is
to do a search on each field separately, but we want to be able to search for
all 3 fields in one search box. Does anyone know how to do this? I have
attached the 2 different types of code for searching in one box, or searching
in 3 boxes that we already have. Thanks.
Andy
This is the first one that has just one search box for all 3 fields:
<CFIF IsDefined("url.FullName")>
<CFSET form.FullName=url.FullName>
</CFIF>
<CFQUERY NAME="ContactSearch" datasource="#application.DataSource#">
SELECT Company, First, Middle, Last,
ContactID, Contact_Num, RFQID, RFQID_SPEC, ItemID, Entry_Date, RFQ_Leader,
Standard_Part_Number, Generic_Description, M2M_Quote_Number,
Sales_Order_Number, Company_Classification, Highest_Quantity_Request,
Date_First_Entered, Address1, Address2, Address3, City, State, Zip, Country,
Phone, Cell_Phone, Fax, Email
<!--- Use this joining code below to display only 1 of each RFQ Number and to
not have multiple items of an RFQ display on the page. This works because of
the ItemID and it's not the RFQID. --->
FROM
(((Contacts LEFT JOIN RFQ_Numbers ON Contacts.ContactID =
RFQ_Numbers.Contact_Num)
LEFT JOIN Companies ON Contacts.Company = Companies.Company_Name)
LEFT JOIN RFQ_SPEC ON RFQ_SPEC.ItemID = RFQ_Numbers.Item_Num)
where 1=1
<cfif listlen(form.fullname,' ') eq 3>
AND First like '%#listgetat(form.FullName,1,' ')#%'
AND Middle Like '%#listgetat(form.FullName,2,' ')#%'
AND Last Like '%#listgetat(form.FullName,3,' ')#%'
<cfelseif listlen(form.fullname,' ') eq 2>
AND First like '%#listgetat(form.FullName,1,' ')#%'
AND Last Like '%#listgetat(form.FullName,2,' ')#%'
<cfelse>
And First like '%#form.FullName#%'
OR Middle Like '%#form.FullName#%'
OR Last Like '%#form.FullName#%'
</cfif>
ORDER BY #set_order#
</CFQUERY>
This is the 2nd one that has 3 separate search boxes for all 3 fields:
<CFIF IsDefined("url.FirstName")>
<CFSET form.FirstName=url.FirstName>
</CFIF>
<CFIF IsDefined("url.MiddleName")>
<CFSET form.MiddleName=url.MiddleName>
</CFIF>
<CFIF IsDefined("url.LastName")>
<CFSET form.LastName=url.LastName>
</CFIF>
<CFQUERY NAME="ContactSearch" datasource="#application.DataSource#">
SELECT Company, First, Middle, Last,
ContactID, Contact_Num, RFQID, RFQID_SPEC, ItemID, Entry_Date, RFQ_Leader,
Standard_Part_Number, Generic_Description, M2M_Quote_Number,
Sales_Order_Number, Company_Classification, Highest_Quantity_Request,
Date_First_Entered, Address1, Address2, Address3, City, State, Zip, Country,
Phone, Cell_Phone, Fax, Email
<!--- Use this joining code below to display only 1 of each RFQ Number and to
not have multiple items of an RFQ display on the page. This works because of
the ItemID and it's not the RFQID. --->
FROM
(((Contacts LEFT JOIN RFQ_Numbers ON Contacts.ContactID =
RFQ_Numbers.Contact_Num)
LEFT JOIN Companies ON Contacts.Company = Companies.Company_Name)
LEFT JOIN RFQ_SPEC ON RFQ_SPEC.ItemID = RFQ_Numbers.Item_Num)
where 1=1
<cfif Len(Trim(form.FirstName))>
AND First like '%#form.FirstName#%'
</cfif>
<cfif Len(Trim(form.MiddleName))>
AND Middle Like '%#form.MiddleName#%'
</cfif>
<cfif Len(Trim(form.LastName))>
AND Last Like '%#form.LastName#%'
</cfif>
ORDER BY #set_order#
</CFQUERY>
Does anyone know how to be able to search on all 3 fields for a First
Name, Middle Name, and a Last Name all in the same search box? I am able to do
this now, but the problem is if there are 2 words in a last name, such as "La
Rue", the search can't find this. The only way I know how to make this work is
to do a search on each field separately, but we want to be able to search for
all 3 fields in one search box. Does anyone know how to do this? I have
attached the 2 different types of code for searching in one box, or searching
in 3 boxes that we already have. Thanks.
Andy
This is the first one that has just one search box for all 3 fields:
<CFIF IsDefined("url.FullName")>
<CFSET form.FullName=url.FullName>
</CFIF>
<CFQUERY NAME="ContactSearch" datasource="#application.DataSource#">
SELECT Company, First, Middle, Last,
ContactID, Contact_Num, RFQID, RFQID_SPEC, ItemID, Entry_Date, RFQ_Leader,
Standard_Part_Number, Generic_Description, M2M_Quote_Number,
Sales_Order_Number, Company_Classification, Highest_Quantity_Request,
Date_First_Entered, Address1, Address2, Address3, City, State, Zip, Country,
Phone, Cell_Phone, Fax, Email
<!--- Use this joining code below to display only 1 of each RFQ Number and to
not have multiple items of an RFQ display on the page. This works because of
the ItemID and it's not the RFQID. --->
FROM
(((Contacts LEFT JOIN RFQ_Numbers ON Contacts.ContactID =
RFQ_Numbers.Contact_Num)
LEFT JOIN Companies ON Contacts.Company = Companies.Company_Name)
LEFT JOIN RFQ_SPEC ON RFQ_SPEC.ItemID = RFQ_Numbers.Item_Num)
where 1=1
<cfif listlen(form.fullname,' ') eq 3>
AND First like '%#listgetat(form.FullName,1,' ')#%'
AND Middle Like '%#listgetat(form.FullName,2,' ')#%'
AND Last Like '%#listgetat(form.FullName,3,' ')#%'
<cfelseif listlen(form.fullname,' ') eq 2>
AND First like '%#listgetat(form.FullName,1,' ')#%'
AND Last Like '%#listgetat(form.FullName,2,' ')#%'
<cfelse>
And First like '%#form.FullName#%'
OR Middle Like '%#form.FullName#%'
OR Last Like '%#form.FullName#%'
</cfif>
ORDER BY #set_order#
</CFQUERY>
This is the 2nd one that has 3 separate search boxes for all 3 fields:
<CFIF IsDefined("url.FirstName")>
<CFSET form.FirstName=url.FirstName>
</CFIF>
<CFIF IsDefined("url.MiddleName")>
<CFSET form.MiddleName=url.MiddleName>
</CFIF>
<CFIF IsDefined("url.LastName")>
<CFSET form.LastName=url.LastName>
</CFIF>
<CFQUERY NAME="ContactSearch" datasource="#application.DataSource#">
SELECT Company, First, Middle, Last,
ContactID, Contact_Num, RFQID, RFQID_SPEC, ItemID, Entry_Date, RFQ_Leader,
Standard_Part_Number, Generic_Description, M2M_Quote_Number,
Sales_Order_Number, Company_Classification, Highest_Quantity_Request,
Date_First_Entered, Address1, Address2, Address3, City, State, Zip, Country,
Phone, Cell_Phone, Fax, Email
<!--- Use this joining code below to display only 1 of each RFQ Number and to
not have multiple items of an RFQ display on the page. This works because of
the ItemID and it's not the RFQID. --->
FROM
(((Contacts LEFT JOIN RFQ_Numbers ON Contacts.ContactID =
RFQ_Numbers.Contact_Num)
LEFT JOIN Companies ON Contacts.Company = Companies.Company_Name)
LEFT JOIN RFQ_SPEC ON RFQ_SPEC.ItemID = RFQ_Numbers.Item_Num)
where 1=1
<cfif Len(Trim(form.FirstName))>
AND First like '%#form.FirstName#%'
</cfif>
<cfif Len(Trim(form.MiddleName))>
AND Middle Like '%#form.MiddleName#%'
</cfif>
<cfif Len(Trim(form.LastName))>
AND Last Like '%#form.LastName#%'
</cfif>
ORDER BY #set_order#
</CFQUERY>