Skip to main content
Inspiring
January 12, 2012
Answered

SELECT IN query using ormExecuteQuery()

  • January 12, 2012
  • 1 reply
  • 6685 views

I'm trying to do a SELECT IN query using ormExecuteQuery().  Following is the code I have:

Categories = ormExecuteQuery("from Category where Id IN (?)",[CategoryList]);

It only works when there is 1 value in the CategoryList.  i.e. This works:

Categories = ormExecuteQuery("from Category where Id IN (?)",[9]);

This DOES NOT work:

Categories = ormExecuteQuery("from Category where Id IN (?)",[8,9,10]);

Help would be greatly appreciated.

This topic has been closed for replies.
Correct answer ccsimmons

This works:

Categories = ormExecuteQuery("from Category where Id IN (:IdList)",{IdList=ListToArray(CategoryList)});

Seems like this would too, but it does not.

Categories = ormExecuteQuery("from Category where Id IN (?)",[ListToArray(CategoryList)]);

1 reply

ccsimmonsAuthorCorrect answer
Inspiring
January 15, 2012

This works:

Categories = ormExecuteQuery("from Category where Id IN (:IdList)",{IdList=ListToArray(CategoryList)});

Seems like this would too, but it does not.

Categories = ormExecuteQuery("from Category where Id IN (?)",[ListToArray(CategoryList)]);