Hi, this query is to search for state and country.
the states are in either ShipToAddr2 or 3 while countries are in ShipToAddr3 or 4 .. thats why it looks like this ...
What I need help on is ... I want to limit the returns to only customers who's SpecialInstrs field is not blank. I dont know if its a problem or not but the SpecialInstrs is a list field for customer codes ... so it could be blank, or could contain several codes separated by a comma.
The query below STILL returns customers even if the SpecialInstrs field is blank . and I dont want it to return it if it is blank.
thanks
<CFQUERY NAME="GetOwnerResults" DATASOURCE="EncoreCompanyD">
SELECT * FROM ArCustomer WHERE 1=1 and SpecialInstrs IS NOT NULL
<cfif #form.SearchState# NEQ "All">
AND ShipToAddr2 like '%, #Searchstate#%'
</cfif>
<cfif #form.SearchState# NEQ "All">
OR ShipToAddr3 like '%, #Searchstate#%'
</cfif>
<cfif #form.SearchState# EQ "Canada">
OR ShipToAddr3 like 'Canada'
</cfif>
<cfif #form.SearchState2# NEQ "All">
OR ShipToAddr3 like '%#Searchstate2#%'
</cfif>
<cfif #form.searchstate2# NEQ "All">
OR ShipToAddr4 like '%#searchstate2#%'
</cfif>
<cfif #form.SearchState3# NEQ "All">
OR ShipToAddr3 like '%#Searchstate3#%'
</cfif>
<cfif #form.searchstate3# NEQ "All">
OR ShipToAddr4 like '%#searchstate3#%'
</cfif>
<cfif #form.SearchState4# NEQ "All">
OR ShipToAddr3 like '%#Searchstate4#%'
</cfif>
<cfif #form.searchstate4# NEQ "All">
OR ShipToAddr4 like '%#searchstate4#%'
</cfif>
<cfif #form.SearchState5# NEQ "All">
OR ShipToAddr3 like '%#Searchstate5#%'
</cfif>
<cfif #form.searchstate5# NEQ "All">
OR ShipToAddr4 like '%#searchstate5#%'
</cfif>
<cfif #form.SearchState6# NEQ "All">
OR ShipToAddr3 like '%#Searchstate6#%'
</cfif>
<cfif #form.searchstate6# NEQ "All">
OR ShipToAddr4 like '%#searchstate6#%'
</cfif>
<cfif #form.SearchState7# NEQ "All">
OR ShipToAddr3 like '%#Searchstate7#%'
</cfif>
<cfif #form.searchstate7# NEQ "All">
OR ShipToAddr4 like '%#searchstate7#%'
</cfif>
Order By Name
</cfquery>
the states are in either ShipToAddr2 or 3 while countries are in ShipToAddr3 or 4 .. thats why it looks like this ...
What I need help on is ... I want to limit the returns to only customers who's SpecialInstrs field is not blank. I dont know if its a problem or not but the SpecialInstrs is a list field for customer codes ... so it could be blank, or could contain several codes separated by a comma.
The query below STILL returns customers even if the SpecialInstrs field is blank . and I dont want it to return it if it is blank.
thanks
<CFQUERY NAME="GetOwnerResults" DATASOURCE="EncoreCompanyD">
SELECT * FROM ArCustomer WHERE 1=1 and SpecialInstrs IS NOT NULL
<cfif #form.SearchState# NEQ "All">
AND ShipToAddr2 like '%, #Searchstate#%'
</cfif>
<cfif #form.SearchState# NEQ "All">
OR ShipToAddr3 like '%, #Searchstate#%'
</cfif>
<cfif #form.SearchState# EQ "Canada">
OR ShipToAddr3 like 'Canada'
</cfif>
<cfif #form.SearchState2# NEQ "All">
OR ShipToAddr3 like '%#Searchstate2#%'
</cfif>
<cfif #form.searchstate2# NEQ "All">
OR ShipToAddr4 like '%#searchstate2#%'
</cfif>
<cfif #form.SearchState3# NEQ "All">
OR ShipToAddr3 like '%#Searchstate3#%'
</cfif>
<cfif #form.searchstate3# NEQ "All">
OR ShipToAddr4 like '%#searchstate3#%'
</cfif>
<cfif #form.SearchState4# NEQ "All">
OR ShipToAddr3 like '%#Searchstate4#%'
</cfif>
<cfif #form.searchstate4# NEQ "All">
OR ShipToAddr4 like '%#searchstate4#%'
</cfif>
<cfif #form.SearchState5# NEQ "All">
OR ShipToAddr3 like '%#Searchstate5#%'
</cfif>
<cfif #form.searchstate5# NEQ "All">
OR ShipToAddr4 like '%#searchstate5#%'
</cfif>
<cfif #form.SearchState6# NEQ "All">
OR ShipToAddr3 like '%#Searchstate6#%'
</cfif>
<cfif #form.searchstate6# NEQ "All">
OR ShipToAddr4 like '%#searchstate6#%'
</cfif>
<cfif #form.SearchState7# NEQ "All">
OR ShipToAddr3 like '%#Searchstate7#%'
</cfif>
<cfif #form.searchstate7# NEQ "All">
OR ShipToAddr4 like '%#searchstate7#%'
</cfif>
Order By Name
</cfquery>