Brett,

If both the list and the number are in the database, you can use:

SELECT number
FROM table
WHERE number IN (SELECT number_list FROM other_table WHERE list_id =  
#list_id#)

If it's not in the database you can use the following:

SELECT list_id
FROM other_table
WHERE #numberVar# IN (SELECT number_list FROM other_table WHERE  
list_id = #list_id#)

If it returns a record it's true, if not, it's false.  You can also  
use an aggregate function to return a true/false value, but that  
depends on your dbms.

Depending on what you're trying to return, you can use a variation on  
your subquery or use joins to limit which list you are comparing.
  (Note:  the second query will work for sure in MySQL and Postgres -  
I assume it will with MSSQL, but I didn't test it.)

HTH,
Jon

On Jan 10, 2007, at 9:09 AM, Brett Wiese wrote:

> I need to compare a number to a list that is contained in a row in  
> a database, to see if it's contained within the list, and therefor  
> include it in the results.
>
> Using LIKE won't work in the long term beacuse it would also find  
> 18 in 118 for example.
>
> I could use listfind() in the output of the query, but i'd rather  
> limit the CFQUERY.
>
> Is there a way to do this?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266152
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to