如果我没有正确解释,我提前道歉。我甚至很难用英语来解释,更不用说在mysql查询中了。
我正在尝试获取具有多个记录的question_id
的response_set_ids
列表。
这是我的数据示例:
+----+-----------------+-------------+-----------+
| id | response_set_id | question_id | answer_id |
+----+-----------------+-------------+-----------+
| 1 | 10 | 1 | 4 |
| 2 | 10 | 2 | 5 |
| 3 | 10 | 3 | 6 |
| 4 | 10 | 3 | 7 |
| 5 | 11 | 1 | 8 |
| 6 | 11 | 2 | 9 |
| 7 | 11 | 3 | 10 |
+----+-----------------+-------------+-----------+
我想要一个查询,返回一个包含 response_set_id 的列表,而在这个特定的示例中,我期望被返回
10
,因为该 response_set 具有多次出现的 question_id -> 3
。如果您需要任何进一步的信息来帮助我,请告诉我。
我已经尝试过这个查询:
select response_set_id, count(question_id) from responses group by response_set_id;
但这只给我返回每个 response_set 中问题的数量。提前感谢!