Nando @ Aria Media

( learning Clojure ColdFusion Lucee Javascript jQuery Angular CSS Linux Apache HTML5 & etc )

Cfqueryparam Setting for SQL ‘in’ Statements

| Comments

When using an SQL IN statement within a ColdFusion query, it is necessary to add the attribute list="true" to the param used for the list. See the example below that selects all employees that have a birthdate in March, April or May.

1
2
3
4
5
6
7
8
9
10
11
public query function findUpcomingBirthdates() {
  var params = {};
  var ml = "3,4,5";
  params.insert( "monthList", { value: ml, cfsqltype: "cf_sql_integer", list: true } );
  var sql = "
      select employeeId, firstName, lastName, birthdate
      from Employee
      where month( birthdate ) in ( :monthList )
  ";
  return queryExecute( sql, params );
}

Thanks to Ben Nadel’s post here for this crucial tidbit of information!

Comments