Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"does not contain" in CAML?

In CAML I can query SharePoint Listitems using the "Contains"-element, but there is no "does not contain"-element I could use.

So what is the best way to get the items that do not contain a string? Is there a better way than to loop through each and every item?

like image 779
user4531 Avatar asked Dec 04 '08 15:12

user4531


1 Answers

The same restriction applies to BeginWith. I do not know any good solution sadly. What you could do: Do a Contains-Query, loop through each item and get the IDs, then do another big query for "ID NotEqual 1 or ID NotEqual 2 or ID NotEqual 3......" Since ID is indexed as far as I know, that should have a smaller impact on the database, but it still smells really bad.

For small list it does not matter, for larger lists i'd use the SQL Server Profiler to see what the impact is.

like image 67
Michael Stum Avatar answered Sep 20 '22 07:09

Michael Stum