0

我有一张这样的桌子:

CREATE TABLE records (_id INTEGER PRIMARY KEY,
                    question TEXT, answer TEXT, category INTEGER)

给出一个特定的类别值(比如说 2),我想从该类别中选择一个随机行。这就是我想象的解决方案:

Select   question, answer, category //I think there is something missing
From     records
Where    category=2

任何帮助将不胜感激!

4

1 回答 1

3

你可以这样:

SELECT question, answer, category
FROM records
WHERE category=2 ORDER BY RANDOM() LIMIT 1;
于 2012-07-20T02:58:47.230 回答