CFQUERY Using Multiple 'and' Statements
Hello,
I am working on a form in which the user inputs 4 values and then the results are returned in a table. The trouble I am running into is that I am getting no results when using multiple 'and' statements. There are no errors thrown, just empty results. If I use the 'or' operator, I get a set resturns, just not as narrowed down as I would like. I have included the relevant code below and any suggestions would be greatly appreciated!!
<body bgcolor="#FFFFFF" topmargin="2" leftmargin="2" rightmargin="2">
<cfform method="post" name="address_value_1" target="blank" action="results.cfm">
<table width="185" border=0 bordercolor="black" cellpadding="0" cellspacing="0" >
<tr>
<td>
<h2 class="surv">The Number: </h2>
</td>
<td align="left" >
<cfinput type="text" name="address_value_new" size="20" maxlength="20" class="whiteonblue">
</td>
<td align="left">
<cfselect name="ns" class="whiteonblack">
<option value="dir_n">N</option>
<option value="dir_s">S</option>
</cfselect>
</td>
<td align="left" >
<cfinput type="text" name="address_value_new_2" size="20" maxlength="20" class="whiteonblue">
</td>
<td align="left">
<cfselect name="EW" class="whiteonblack">
<option value="dir_e">E</option>
<option value="dir_w">W</option>
</cfselect>
</td>
</tr>
<tr>
<td align=center colspan="2">
<INPUT TYPE="submit" VALUE="go">
</td>
</tr>
</table>
</cfform>
results.cfm
<CFQUERY name="by_address" datasource="sire" dbtype="odbc">
select *
FROM sire.dbo.control_doc
WHERE sire.dbo.control_doc.publish = 'yes'
and
sire.dbo.control_doc.grid_ns like '%#form.address_value_new#%'
and sire.dbo.control_doc.direction_ns like '%#form.ns#%'
and sire.dbo.control_doc.grid_ew like '%#form.address_value_new_2#%'
and sire.dbo.control_doc.direction_ew like '%#form.ew#%'
</CFQUERY>
