要实现多项选择测验,我想从答案表中选择答案(“正确”答案)和两个“不正确”的答案。我可以在一个查询中执行此操作。我觉得我应该可以,但我不太明白。以下是我到目前为止的情况:
SELECT correct.answer
FROM (
SELECT answer
FROM answers
ORDER BY random()
LIMIT 1
) correct
UNION
SELECT answer
FROM (
SELECT DISTINCT answer
FROM answers
WHERE answer != correct.answer
ORDER BY random()
LIMIT 2
);
数据库引擎是SQLite 3,它给了我:
Error: no such column: correct.answer
我可以通过两个单独的查询来完成,但就像我说的那样,一个应该是可能的吗?