我有一个带有问题表的数据库,每个问题都有一个级别属性,主题和答案。我想在ASP.net项目中随机提问,但我不希望在详细信息视图中重复相同的问题。
这是select语句:
SELECT TOP 3 [Question Number] AS Question_Number
,[Question Title] AS Question_Title
,[Answer 1] AS Answer_1
,[Answer 2] AS Answer_2
,[Answer 3] AS Answer_3
,QuizID
,Level
FROM Question
WHERE ( Level = 1 )
ORDER BY NEWID()
答案 0 :(得分:1)
我不这么认为,除非你在表格中有重复的记录,否则你会得到重复的行。如果您已经使用DISTINCT从表中获取唯一记录。
用于消除重复记录的DISTINCT关键字的基本语法如下:
SELECT DISTINCT column1,column2,... columnN FROM table_name WHERE [condition]