DAV: How To Search mv.string Properties

The following SEARCH will return items which have been associated with the “Business” category but NOT the “Competition” category in Outlook.

<?xml version='1.0'?>

<D:searchrequest xmlns:D='DAV:'>

   <D:sql>

   SELECT "DAV:href", "urn:schemas-microsoft-com:office:office#Keywords"

   FROM SCOPE ( 'SHALLOW TRAVERSAL OF

         "http://mstehleEx03/exchange/mrmet/Calendar/"' )

   WHERE

       "DAV:isfolder"= false

       AND

       "DAV:ishidden" = false

   AND

      "urn:schemas-microsoft-com:office:office#Keywords" != CAST("Competition" AS 'mv.string')

       AND

       "urn:schemas-microsoft-com:office:office#Keywords" = CAST("Business" AS 'mv.string')

   </D:sql>

</D:searchrequest>

...We don’t seem to have any samples out there that demonstrate how to use a multivalued property in a WHERE clause. I took me a bit to figure this out because the behavior is kind of funny…

Notice that even though we are specifying “=” it behaves similar to a LIKE or CONTAINS query…

Suppose you have two items in a folder Item A with the “Business” category and Item B with “Business” and “Competition”. If this query just had the clause for “Business” then both items would be returned. However, if you use specify that theKeywords must equal “Business” and not equal “Competition” then you only get Item A.