Care with CAML query logical joins

CAML (Collaborative Application Markup Language) is the markup used to specify search queries using the SPQuery class. The schema can be found here. Another useful link is the value types allowed in the tag, here.

One might infer that and tags can contain any number of comparison operator tags, but this is incorrect. Each logical join must have exactly two tags inside, and they can be either comparison operators or nested logical joins. Thus, to produce logical joins with three or more clauses, you must do something like this:


The error that occurs when an arbitrary number of tags are nested is:

One or more field types are not installed properly. Go to the list settings page to delete these fields.

This error is not descriptive of this problem. It is more typically describing a problem where a field’s ‘friendly’ name (as seen in the web UI) has been specified in the FieldRef tag instead of its internal name.