Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
spacehog #1
using list in subquery
I have a query that I would like to pass a list of values to use in the WHERE
statement. How do I use a list in the WHERE statement?
Example:
<cfset list = "a,b,c">
SELECT *
FROM table
WHERE id IN ('#list#')
ColdFusion reads the above query as:
SELECT *
FROM table
WHERE id IN ('a,b,c')
It read the list as a single string instead of:
SELECT *
FROM table
WHERE id IN ('a',b','c')
I remember hearing of a way to insert the needed quotes, but I have forgotten.
spacehog Guest
-
Avoiding subquery
Hi, if anyone feels like a little quiz (but I don't know the answer), just for interest: Is it possible to rewrite this: SELECT... -
Subquery
I am trying to update a table with data in a "look up table." Specifically, I have a table that contains zip codes but is missing both city &... -
SQL subquery question
I have a query running inside of Coldfusion webpage. query blah cfoutput query blah { query another_blah { cfoutput another_blah -
Select From SubQuery
Yes you can create pseudo tables and reference them in the outer query as you have done. -- HTH, SriSamp Please reply to the whole group only! ... -
subquery with more than 1 fields
select * from ordermaster where (orderid,customerid) in select orderid,customerid from orderdetail the sql can't be run in ms sql and is there... -
zoeski80 #2
Re: using list in subquery
Hey SpaceHog
I think ListQualify is the function you're after.
Zoe
zoeski80 Guest
-
anclarke #3
Re: using list in subquery
As long as you're not using a stored procedure, just do something like this:
where id in ('#replace(list, ',', '','', 'ALL')#') So, your ids are character
strings and not numeric? If they're numeric and you're using MSSQL, you'll
just want to do it like: where id in (#list#) It doesn't matter which way you
do it if you're using MySQL, IIRC. Now I have a question for you: how do you
get your code to look all nice like that when you post it in this forum? HTH
& Thanks :-) - Andrew.
anclarke Guest
-
anclarke #4
Re: using list in subquery
Hmm duh yeah. Forget what I said: use listQualify(). I never do that myself so I didn't even know that existed!
- Andrew.
anclarke Guest



Reply With Quote

