基本上我希望在dropdownlist中随机显示项目,任何函数都可以使用吗?
输出
一
B'/ P>
C
预期输出(可以是任何但不仅仅是abc)
B'/ P>
一
C
OR
C
一
B'/ P>
OR
任何
asp:Label ID =“Label3”Text ='<%#DataBinder.Eval(Container.DataItem,“Question”)%> 'Runat =“server”
选择* from(SELECT [r1] AS [Option] FROM [ExerciseTable] WHERE([Question] = @Question)
UNION SELECT [r2] AS [Option] FROM [ExerciseTable] WHERE([Question] = @Question)UNION
SELECT [r3] AS [Option] FROM [ExerciseTable] WHERE([Question] = @Question AND
[r3]!= null))t由Newid()命令“
答案 0 :(得分:0)
您可以使用Newid()
获取随机顺序
SELECT *
FROM (SELECT [r1] AS [Option]
FROM [ExerciseTable]
WHERE ( [Question] = @Question )
UNION
SELECT [r2] AS [Option]
FROM [ExerciseTable]
WHERE ( [Question] = @Question )
UNION
SELECT [r3] AS [Option]
FROM [ExerciseTable]
WHERE ( [Question] = @Question
AND [r3] != NULL )) t
ORDER BY Newid()
<强>更新强>
FOR TEST:
代码:
SELECT *
FROM (SELECT 'a' AS col
UNION
SELECT 'b' AS col
UNION
SELECT 'c' AS col) t
ORDER BY Newid()
第一次
第二次