Using lists IN queries

Today I came across an interesting issue which I thought I would share the solution as it took a bit of searching to find out how to do this. It breaks down like this… I had a this query:

SELECT     version_id
FROM version_category_xref
WHERE category_uuid IN (#arguments.lCategories#)

This didnt work at first as the list in the where clause did not have the obligatory ‘ quotes around the list items.

Rather than doing a loop through the list inserting these I thought that cold fusion must have thought of a way around this and I was right… !

By changing the WHERE clause to:

WHERE     category_uuid IN (#ListQualify(arguments.lCategories,"'",",","ALL")#)

Hopefully this might help anyone out there searching for an easy way to do this like I was 10 minutes ago.

Comments
Add New
Powered by !JoomlaComment 3.26

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Help my beer fund

RocketTheme Joomla Templates