ColdFusion:SQL从查询中选择IN [英] ColdFusion: SQL Select IN from a Query

查看:106
本文介绍了ColdFusion:SQL从查询中选择IN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SQL Server查询,该查询返回一个MyBusinessUnit列的两个值,并返回两个值,例如:

I have a SQL Server query which returns two values for one MyBusinessUnit column returns two values, say:

1111

2222

在名为MyQuery1

这两个值还存在于DB2数据库的MyCorpUnit列中.

Both of these values also exist in a DB2 database's MyCorpUnit column.

我想要从DB2表中选择所有匹配的记录-不,跨数据库查询不起作用.

What I want is to select all the matching records from the DB2 table--and, no, cross database queries are NOT working.

因此,这是我的Query2 for DB2数据库:

So, here's my Query2 for DB2 database:

 <cfquery name="Query2" datasource="#application.DSN#"> 
  SELECT MyCorpUnit WHERE MyCorpUnit IN
  (    
     <cfqueryparam value="   #Query1.MyBusinessUnit #" CFSQLType="cf_sql_varchar" />
  )
 </cfquery>

但是Query2仅返回一个值(1111)的匹配记录.

But Query2 only returning matching record for only one value (1111).

因此需要一些其他方法.我已经尝试创建一个字符串,但是那也不起作用.

So some other approach is needed. I have tried to create a string but that didn't work either.

有什么主意吗?

谢谢!

推荐答案

cfqueryparam具有 list 属性,该属性可能会有所帮助:

cfqueryparam has a list attribute which might help:

<cfqueryparam value = "parameter value" 
        CFSQLType = "parameter type" 
        list = "yes|no" 
        maxLength = "maximum parameter length" 
        null = "yes|no" 
        scale = "number of decimal places" 
        separator = "separator character"> 
    AND/OR ...additional criteria of the WHERE clause...> 

我以前使用过它,但是不确定它是否在QoQ中. :D

I've used it before but not sure if it was in a QoQ or not. :D

ref: http://help.adobe.com /en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f6f.html

这篇关于ColdFusion:SQL从查询中选择IN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆