Reputation: 2354
I'm trying to learn linq..I have the following linq query..
var abc = consumers.Where(w => plays.Any(x => x.consumerid == w.consumerid));
I would appreciate if someone could help me with its corresponding sql query.
consumers have just two fields.. consumerid and period both string. plays also have two fields.. consumerid and playid both string.
Based on answer here.. I tried abc.ToString() but that did not help..
Upvotes: 0
Views: 519
Reputation: 328
Simplified query:
SELECT *
FROM consumers x
WHERE EXISTS
(
SELECT *
FROM plays w
WHERE x.consumerid = w.consumerid
)
Upvotes: 1
Reputation: 1
Try this:
select * from consumers c left join palys p on c.consumerid = p.consumerid
Upvotes: 0