本文介绍了选择一个随机行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi All
我试图从SQL中选择一个类似于以下SQL代码的随机行:
ALTER PROCEDURE WebUser.GetPhoto | |
( | |
@GalleryID int = -1 | |
) | |
AS | |
SET NOCOUNT ON | |
SELECT TOP 1 | |
PhotoID, | |
[名称 ], | |
PhotoPath | |
FROM 照片 | |
WHERE GalleryID = @GalleryID OR @ GalleryID = -1 | |
ORDER BY NewID() | |
RETURN |
解决方案
Hi All
I am trying to select a single random row from SQL similar to the following SQL code:
ALTER PROCEDURE WebUser.GetPhoto | |
( | |
@GalleryID int = -1 | |
) | |
AS | |
SET NOCOUNT ON | |
SELECT TOP 1 | |
PhotoID, | |
[Name], | |
PhotoPath | |
FROM Photo | |
WHERE GalleryID = @GalleryID OR @GalleryID = -1 | |
ORDER BY NewID() | |
RETURN |
解决方案
这篇关于选择一个随机行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-23 16:04