Knowledgebase

Knowledgebase ID# :: 3134

How to write AssetQuery metafilter using SQL LIKE statement between 2 very related values

subject: code example
product: Serena Collage version: [All]

The following example should help Collage developers write a metafilter for an AssetQuery component that will use a SQL LIKE statement to find values for metadata where one value can be contained within a longer, similar value.  For instance, if you need to search for values of 'Retirees' you would write a sql statement such as: 

WHERE Target_Audience LIKE '%Retirees%'

I am also placing a second '%' wildcard character because we are writing this against a CUSTOM Collage Metadata where we are forcing a separation characters between each value where multiple values are possible.  In this case, we do not want a similar value of 'Pre-Retirees' to display in our result set.  We would then write the SQL statement as such:

WHERE Target_Audience LIKE '%[^P][^r][^e][^-]Retirees%'

So, our AssetQuery metafilter attribute value could be:

metafilter="M.Name='Target_Audience' AND (M.Value LIKE '%[^P][^r][^e][^-]Retiree%')"