如何从表行中获取随机值 [英] How to get Random Value from Table Row

查看:79
本文介绍了如何从表行中获取随机值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将表格中的数据放在一列中,并希望在ASP.NET 4.0 C#文本框上加载页面时从表格中随机选择一个数据.

i''ve data on table in one column and want to select one data from table randomly while loading a page on ASP.NET 4.0 C# textbox. how to do it

推荐答案

您没有提及是否要通过SQL查询,代码或其他方式来执行此操作,但是您想使用SQL,并且您拥有SQL Server,那么选择随机行的一种方法是
You didn''t mention if you want to do this with a SQL query or in code or something else, but if you want to use SQL and you have SQL Server then one way to select a random row is
SELECT TOP 1 * FROM YourTable ORDER BY NEWID()


感谢Mika,Wendelius和Wes Aday的良好响应.现在解决了
Thank you Mika, Wendelius, Wes Aday for your good response. It''s solved now


这篇关于如何从表行中获取随机值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆