我正在根据排序查询得到的结果尝试更新/插入行的值,按索引查找元素然后更改它。
我正在寻找一种索引结果的方法,但我找不到任何东西。
这是我得到的:
SELECT CASE WHEN COUNT(*)>= 3
THEN Answers.answer_id
ELSE COUNT(*) END
FROM Answers
WHERE Answers.question_id = 12
ORDER BY Answers.answer_id ASC
我想在找到满足要求的值或指定索引值时停止计数。
名为问题的表1有2个值:
uint8 - question_id
string - question
名为Answers的表号2有3个值:
uint8 - answer_id
string - answer
uint8 - question_id
我需要检查给定答案的顺序并更改它的值。
例如,使用此查询:
SELECT Answers.answer_id
FROM Answers
WHERE Answers.question_id = 12
ORDER BY Answers.answer_id ASC
响应是(这是answer_id的):
34 (index would be 0)
35 (index would be 1)
36 (index would be 2)
37 (index would be 3)
38 (index would be 4)
39 (index would be 5)
而不是那些id我需要索引或在count达到想要的数字时停止计数,然后在索引存在时更新值。