0

如何在 cfscript 中构造 IN 子句?这是我所拥有的:

var tagList = "301,302,303,304";
var q = new Query ();
q.setDatasource ("mydatasource");

var sqlStmt = "SELECT * FROM Tags WHERE tagID IN (:tagList)";

// I know the next line is not correct!
q.addParam (name="tagList", value="#tagList#", cfsqltype="??? WHAT SHOULD IT BE ???");

有没有一种简单的方法可以做到这一点,还是我需要遍历标签列表,分别添加每个标签?

4

1 回答 1

12

有一个<cfqueryparam>应该支持的列表属性:

q.addParam (name="tagList", value="#tagList#", cfsqltype="CF_SQL_INTEGER", list="yes");
于 2012-12-11T09:24:07.990 回答