2019-03-28 SQL Server select 1
select 1 是比select *更有效率的写法
因为它不返回具体的数据记录,而是返回n行的1
select 1 from students
select class,count(1) as pax from students group by class
作用:可以用来查询表中是否有符合条件的记录(比如select 1 from seckill where id = 1001;),
select 1一般用来当作条件使用,比如exists( select 1 from 表名)等。select 1的效率比select 列名和select*快,因为不用查字典表。
if (Select 1 from TrustManagement.Trust where TrustCode=@TrustCode) is null begin insert into TrustManagement.Trust(TrustCode)values(@TrustCode) end