Skip to main content
Known Participant
August 12, 2008
Answered

Checking against a query with CFIF

  • August 12, 2008
  • 11 replies
  • 1520 views
Hi everyone,
I have a small problem that I can't seem to solve no matter how much I search.

I have a database column with values 10001, 10002, and 10003 that represent text (i.e., apple, orange, pear)
In coldfusion, I query the database for that column and then use a CFIF statement to test for the 3 possible values. I always end up getting a value of "Orange" and never get anything else, although there are different values in the database.
Can anyone enlighten me? The code is attached below
This topic has been closed for replies.
Correct answer A***
<!--- I suggest name/value pairs structure from which you can pull out your fruit value --->

<cfset getNotes[10002] = "Orange" />
<cfset getNotes[10001] = "Apple" />
<cfset getNotes[10003] = "Pear" />

<!--- For process_id 10001 output its fruit --->
<cfset process_id = "10001" />
<cfoutput>#getNotes[process_id]#</cfoutput><br />

<!--- Same for others --->
<cfset process_id = "10002" />
<cfoutput>#getNotes[process_id]#</cfoutput><br />
<cfset process_id = "10003" />
<cfoutput>#getNotes[process_id]#</cfoutput>

11 replies

Inspiring
August 12, 2008
freedomflyer wrote:
> I have a database column with values 10001, 10002, and 10003

What is the data type of your column? Can you give a few examples of query values that incorrectly return "Orange"?

> <cfif #getNotes.process_id# IS 10002>

BTW, having nothing to do with your current problem you do not need the extra # signs there.