开发者

usage of select null?

开发者 https://www.devze.com 2023-02-08 17:02 出处:网络
I see that some examples 开发者_Go百科uses select statement with null. When to use: select null from etc. etc.?

I see that some examples 开发者_Go百科uses select statement with null. When to use:

select null from etc. etc.?


Select null is usually used in combination with EXISTS.

eg:- IF EXISTS( select null from ...)

It sets up the Exists status as true if there are records in the select query. Check this link which has some interesting comments on the usage of select null with Exists: SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table)


Linq to SQL do this sort of thing :

Select * 
From Foo f 
Where Exists
(   
    Select null 
    From Bar b 
        on b.fooId = f.id
)

It prevents to bring data when I don't want data, but just the exist status.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号