SQL Select Query中Top 1 1和Select 1之间的差异 [英] Diff between Top 1 1 and Select 1 in SQL Select Query
问题描述
我对 sql 有一个普遍的疑问.实际上Top 1 1"会做什么?以下查询的含义是什么?
I have a general doubt in sql. What is actually "Top 1 1" will do ? What is the meaning of the below query ?
select top 1 1 from Worker W where not exists (select 1 from Manager M where M.Id = W.Id)
sql server 查询中 select "TOP 1 1" 和 "SELECT 1" 的区别是什么?
what is the diff between select "TOP 1 1" and "SELECT 1" in sql server query ?
推荐答案
SELECT TOP 1
表示选择结果集中的第一条记录
SELECT TOP 1
Means Selecting the very 1st record in the result set
SELECT 1
表示返回1作为结果集
SELECT 1
Means return 1 as the result set
SELECT TOP 1 1 FROM [SomeTable] WHERE <SomeCondition>
表示如果条件为真并且选择返回任何行,则只返回顶部 1
行并且只返回该行的整数 1
(没有数据只返回整数 1).
SELECT TOP 1 1 FROM [SomeTable] WHERE <SomeCondition>
Means if the condition is true and any rows are returned from the select, only return top 1
row and only return integer 1
for the row (no data just the integer 1 is returned).
这篇关于SQL Select Query中Top 1 1和Select 1之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!