What does it mean by select 1 from table?

前端 未结 15 1881
南方客
南方客 2020-12-07 07:32

I have seen many queries with something as follows.

Select 1  
From table

What does this 1 mean, how will it be executed and,

15条回答
  •  天涯浪人
    2020-12-07 07:54

    This is just used for convenience with IF EXISTS(). Otherwise you can go with

    select * from [table_name]

    Image In the case of 'IF EXISTS', we just need know that any row with specified condition exists or not doesn't matter what is content of row.

    select 1 from Users

    above example code, returns no. of rows equals to no. of users with 1 in single column

提交回复
热议问题