Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having problem with WHERE condition

Status
Not open for further replies.

Kenfng

Technical User
Feb 11, 2001
4
FR
I'm stumpted. I have a filed defined in ACCESS as text and I want to compare it to some values that I am getting from the database. I have to first concatenate the 4 numeric fields and then pass it on to another form to do the query. My problem is that the comparison never works. If I just do a simple WHERE slvc = '042A', I have no problems with it, but if I use WHERE slvc = '#sl#', i don't get any results. I have tried different combinations with the WHERE clause, but nothing. The match doesn't seem to work.
Thanks in advance if any guys/gals with your help.

<CFSET slv = '#caclval##location##causecl##causeval#'>
<a href=&quot;javascript:NewWin=window.open ('DetailsWindow.cfm?sl=#slv#', 'showwindow', 'toolbar=no,status=no,width=550,height=570'); NewWin.focus();&quot;onmouseover=&quot;window.status='Click here'; return true;&quot;onmouseout=&quot;window.status=''; return true;&quot;
>Click here</a>

================================================

<CFQUERY DATASOURCE = &quot;mysadb&quot; NAME = &quot;getslcv&quot; CACHEDWITHIN=&quot;2&quot;>
SELECT *
FROM slcv_context
WHERE slcv = '#sl#'
</CFQUERY>


Kenneth
 
Hi Kenneth,

I would output the value of #sl# before your query like this.

<cfoutput>~#sl#~</cfoutput>
<CFQUERY DATASOURCE = &quot;mysadb&quot; NAME = &quot;getslcv&quot;
CACHEDWITHIN=&quot;2&quot;>
SELECT *
FROM slcv_context
WHERE slcv = '#sl#'
</CFQUERY>

The ~ marks will help you spot if you have somehow picked up whitespace in #sl#. Since your hard coded value for sl works and the dynamic query with #sl# doesn't, the most likely problem is that #sl# isn't the same as the hard coded value. In your original post, you don't show a <cfoutput> tag so make certain your javascript code is between <cfoutput></cfoutput> tags. If it isn't, you'll pass the text string &quot;#sl#&quot; instead of the value of #sl#.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top