Eric
Eric

Reputation: 505

TSQL to CAML Where value IN OTHER 2010 SP list

After much research, I can't seem to find a CAML equivalent of

SELECT i.Name, i.SubmitDate
FROM issues i 
WHERE i.ServerName IN (
    SELECT s.Name
    FROM servers s 
    WHERE s.Active = true
)

Or

SELECT i.Name, i.SubmitDate
FROM issues i 
INNER JOIN servers s ON s.Name = i.ServerName
WHERE s.Active = true

This is what I have so far. I've tried <Includes> and <In> but I can't seem to get the syntax. Or maybe I approaching this wrong. I can't use LINQ either as i need to pass the CAML query into the SharePoint client object model Any ideas?

<Query>

<Where>
<Includes>
<FieldRef Name="Name" />
<Value Type="Lookup" />
</Includes>
</Where>

<ViewFields>
<FieldRef Name="Name" />
<FieldRef Name="SubmitDate" />
</ViewFields>

</Query>

Upvotes: 0

Views: 50

Answers (1)

shawnt00
shawnt00

Reputation: 17925

I'm not sure why you object to the original query and I don't know CAML. But this query should be equivalent:

SELECT i.Name, i.SubmitDate
FROM issues i INNER JOIN servers s ON s.Name = ServerName
WHERE s.Active = true

Upvotes: 1

Related Questions