Can someone help me on about this. I have a search form with two operators "and" "or"
The query is working when I click "and" but not working when I click "or", it seems query not ending.
Here is the query:
SELECT Parkcode_XREF.Parkcode1, Parkcode_XREF.Proj_ID, Parkcode_XREF.Subject, ID.Dataset_ID, CI.Title, CI.Publication_Date, CO.Person_Name, ID.Abstract, Parkcode_XREF.Parkname1, Parkcode_XREF.Modifiedon, ID_Thesaurus_Keyword.Keyword_Name, MR.Standard_Name, ADDRESS.PARKCODE, ADDRESS.PARKNAME
FROM CO, CO_Address, CI, ID, Parkcode_XREF, MR, ID_Thesaurus, ID_Thesaurus_Keyword, Address
where CO.Contact_ID = CO_Address.Contact_ID AND CO.Contact_ID = CO_Address.Contact_ID and ID.Dataset_ID = Parkcode_XREF.Dataset_ID and ID.Dataset_ID = MR.Dataset_ID AND Parkcode_XREF.Dataset_ID = MR.Dataset_ID and CI.Citation_ID = ID.Citation_ID and CO.Contact_ID = ID.Contact_ID and ID_Thesaurus_Keyword.Thesaurus_ID=#q2.Thesaurus_ID# and #q3.Dataset_ID# = ID_Thesaurus.Dataset_ID and Parkcode_XREF.Parkcode1 = ADDRESS.PARKCODE and Parkcode='#park1.Parkcode#' and ID.Deleted like 0
<cfif search_for1 NEQ "">
and (lower(Parkcode) like '%#lcase(search_for1)#%'
or lower(Abstract) like '%#lcase(search_for1)#%' or lower(Person_Name) like '%#lcase(search_for1)#%'
or lower(Title) like '%#lcase(search_for1)#%' or lower(Proj_ID) like '%#lcase(search_for1)#%' or lower(Subject) like '%#lcase(search_for1)#%')
</cfif>
<cfif search_for2 NEQ "">
<cfif search_term2 EQ "AND">
AND (lower(Parkcode) like '%#lcase(search_for2)#%'
or lower(Abstract) like '%#lcase(search_for2)#%' or lower(Person_Name) like '%#lcase(search_for2)#%'
or lower(Title) like '%#lcase(search_for2)#%' or lower(Proj_ID) like '%#lcase(search_for2)#%' or lower(Subject) like '%#lcase(search_for2)#%')
<cfelseif search_term2 EQ "OR">
OR (lower(Abstract) like '%#lcase(search_for2)#%' or lower(Person_Name) like '%#lcase(search_for2)#%'
or lower(Title) like '%#lcase(search_for2)#%' or lower(Proj_ID) like '%#lcase(search_for2)#%' or lower(Subject) like '%#lcase(search_for2)#%')
</cfif>
</cfif>
The query is working when I click "and" but not working when I click "or", it seems query not ending.
Here is the query:
SELECT Parkcode_XREF.Parkcode1, Parkcode_XREF.Proj_ID, Parkcode_XREF.Subject, ID.Dataset_ID, CI.Title, CI.Publication_Date, CO.Person_Name, ID.Abstract, Parkcode_XREF.Parkname1, Parkcode_XREF.Modifiedon, ID_Thesaurus_Keyword.Keyword_Name, MR.Standard_Name, ADDRESS.PARKCODE, ADDRESS.PARKNAME
FROM CO, CO_Address, CI, ID, Parkcode_XREF, MR, ID_Thesaurus, ID_Thesaurus_Keyword, Address
where CO.Contact_ID = CO_Address.Contact_ID AND CO.Contact_ID = CO_Address.Contact_ID and ID.Dataset_ID = Parkcode_XREF.Dataset_ID and ID.Dataset_ID = MR.Dataset_ID AND Parkcode_XREF.Dataset_ID = MR.Dataset_ID and CI.Citation_ID = ID.Citation_ID and CO.Contact_ID = ID.Contact_ID and ID_Thesaurus_Keyword.Thesaurus_ID=#q2.Thesaurus_ID# and #q3.Dataset_ID# = ID_Thesaurus.Dataset_ID and Parkcode_XREF.Parkcode1 = ADDRESS.PARKCODE and Parkcode='#park1.Parkcode#' and ID.Deleted like 0
<cfif search_for1 NEQ "">
and (lower(Parkcode) like '%#lcase(search_for1)#%'
or lower(Abstract) like '%#lcase(search_for1)#%' or lower(Person_Name) like '%#lcase(search_for1)#%'
or lower(Title) like '%#lcase(search_for1)#%' or lower(Proj_ID) like '%#lcase(search_for1)#%' or lower(Subject) like '%#lcase(search_for1)#%')
</cfif>
<cfif search_for2 NEQ "">
<cfif search_term2 EQ "AND">
AND (lower(Parkcode) like '%#lcase(search_for2)#%'
or lower(Abstract) like '%#lcase(search_for2)#%' or lower(Person_Name) like '%#lcase(search_for2)#%'
or lower(Title) like '%#lcase(search_for2)#%' or lower(Proj_ID) like '%#lcase(search_for2)#%' or lower(Subject) like '%#lcase(search_for2)#%')
<cfelseif search_term2 EQ "OR">
OR (lower(Abstract) like '%#lcase(search_for2)#%' or lower(Person_Name) like '%#lcase(search_for2)#%'
or lower(Title) like '%#lcase(search_for2)#%' or lower(Proj_ID) like '%#lcase(search_for2)#%' or lower(Subject) like '%#lcase(search_for2)#%')
</cfif>
</cfif>