之所以提出这点在这里就是因为select刷选的记录只有一条
当出现多条重复的记录时,只选择最后一条。
1.select * from cc
declare @wexam int
select @wexam =wexam from cc
where sno=95005
print @wexam
go
表cc:
在表cc中存在两条sno相同的记录,
在不进行order by 排序时就直接会显示1.的代码显示的结果为-77,
使用order by
2.select
本文介绍了在SQL Server 2008中使用DECLARE-SELECT时的一个潜在问题:当查询返回多条重复记录时,只选取了最后一条。通过示例展示了未使用ORDER BY与使用ORDER BY时的不同结果,强调了在处理可能有重复记录的查询时,ORDER BY的重要性。
之所以提出这点在这里就是因为select刷选的记录只有一条
当出现多条重复的记录时,只选择最后一条。
1.select * from cc
declare @wexam int
select @wexam =wexam from cc
where sno=95005
print @wexam
go
表cc:
在表cc中存在两条sno相同的记录,
在不进行order by 排序时就直接会显示1.的代码显示的结果为-77,
使用order by
2.select