Need to write a CAML Query that filters against a Lookup Column?

There are two options to do this — one is based on the value and the other on the ID.  Unfortunately MSDN doesn’t provide any help at all on the 2nd option.

Standard what (based on value):

<Where>
    <Eq>
        <FieldRef Name=”Category” />
        <Value Type=”Lookup”>My category</Value>
    </Eq>
</Where>

And by ID:

<Where>
    <Eq>
        <FieldRef Name=”Category” LookupId=”TRUE” />
        <Value Type=”Lookup”>234</Value>
    </Eq>
</Where>

Leave a Reply

Close Menu