Ask a Question related to Coldfusion Database Access, Design and Development.
-
mjmcevoy #1
Using WHERE with variables.
How do I format my SQL so it can select things from the database when i'm
trying to find something in a variable with multiple values.
In the below code, #FORM.building will end up returning several results. eg.
CAPEN_10,CAPEN_14,CAPEN_21.
If any of these results are in the table as "InfoSourceName" I want it to give
me the corrosponding "ComboFall".
<cfquery name="Recordset1" datasource="Fake_Matrix">
SELECT InfoSourceName, ComboFall
FROM tblRoomMatrix
WHERE InfoSourceName IN ('#FORM.building#')
</cfquery>
If I make it so that #FORM.building# only has one value, and i change the SQL
to "=" it works fine.
mjmcevoy Guest
-
#39833 [NEW]: Session variables overwritten by local variables (register_globals=off)
From: sup1382 at accedo dot es Operating system: OpenBSD 3.9 PHP version: 5.2.0 PHP Bug Type: Session related Bug... -
#39447 [NEW]: Want to optionally handle apc_upload_progress variables using session variables
From: krudtaa at yahoo dot com Operating system: All PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug... -
Global variables - application variables vs include file
What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include... -
Replacing code based on static variables to variable variables.
Can anyone give me some help or tips in converting this code to take 2 variables that will specify the number of Pack type lines and the number of... -
variables that change session variables
Hi, I'm currently writing a mulit-page form app that uses a session to retain data from each form element in order for the user to jump between... -
JMGibson3 #2
Re: Using WHERE with variables.
IN clause is similar to =, =>, between, etc. in that if it's a text field the
values must be in quotes (with a comma separator), whereas if they're Dates or
Numbers you don't use quotes. You could build a loop to add the quotes
yourself or the ListQualify function will do it for you. Be aware that ALL
list functions ignore nulls, A,B,C,,D,,E has 4 elements not 6.
Finally, whichever method you chose, you will need the PreserveSingleQuotes
function so that your quotes don't get doubled up.
WHERE InfoSourceName IN (#PreserveSingleQuotes(myNewListWithQuotesAdded)#)
JMGibson3 Guest
-
Dan Bracuk #3
Re: Using WHERE with variables.
Originally posted by: mjmcevoy
I'm sorry, don't know how I that is done. If you have time could you go a
little more in depth. Thank you.
Change this
WHERE InfoSourceName IN ('#FORM.building#')
to this
WHERE InfoSourceName IN (#listqualify(FORM.building)#)
Details are in the cfml reference library. If you don't have one, the
internet does.
Dan Bracuk Guest
-



Reply With Quote

