I\'m trying to construct a query that will include a column indicating whether or not a user has downloaded a document. I have a table called HasDownloaded with the followin
WHERE HasDownloaded.memberId IS NULL OR HasDownloaded.memberId = @memberId
would be the normal way to do that. Some would shorten it to:
WHERE COALESCE(HasDownloaded.memberId, @memberId) = @memberId
You can, as Matt B. shows, do it in your JOIN condition - but I think that's much more likely to confuse folks. If you don't understand WHY moving it to the JOIN clause works, then I'd strongly suggest staying away from it.