traport
asked on
SQL query of a ColdFusion List
I have a query and I'm trying to see if one of the SQL variables is LIKE one of the items in a list. At the end of the query I have
AND tblPerson_RTIDetail.person Unit IN (#PreserveSingleQuotes(ses sion.userR oleUnits)# )
This appears to be doing only a direct match. Can I use "LIKE" in place of "IN" and, if so, how would I place the %?
Thanks a lot!
AND tblPerson_RTIDetail.person
This appears to be doing only a direct match. Can I use "LIKE" in place of "IN" and, if so, how would I place the %?
Thanks a lot!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes it will have multiple values.
Why is it a dangerous function? Thanks for bringing it to my attention.
I'll go try this now.
Why is it a dangerous function? Thanks for bringing it to my attention.
I'll go try this now.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If #session.userRoleUnits# contains multiple values - then NO. What you could do is loop through the list and generate a LIKE statement for each one as @nmarano described above
WHERE .....
<cfloop list="#session.userRoleUni
AND tblPerson_RTIDetail.person
</cfloop>
#PreserveSingleQuotes(sess
( I've probably mentioned it before, but that's a very dangerous function to use on sql server )