What does it mean by select 1 from table?

前端 未结 15 1878
南方客
南方客 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 08:06

    To be slightly more specific, you would use this to do

    SELECT 1 FROM MyUserTable WHERE user_id = 33487
    

    instead of doing

    SELECT * FROM MyUserTable WHERE user_id = 33487
    

    because you don't care about looking at the results. Asking for the number 1 is very easy for the database (since it doesn't have to do any look-ups).

提交回复
热议问题