如何获得project_id,其中一行有tech_id = 1和technology_id = 2?
+------------+---------------+
| project_id | technology_id |
+------------+---------------+
| 1 | 1 |
| 1 | 2 |
| 3 | 2 |
| 7 | 1 |
| 9 | 1 |
+------------+---------------+
答案 0 :(得分:1)
按product_id
分组,只选择那些同时拥有technology_id
s
select project_id
from your_table
where technology_id in (1,2)
group by project_id
having count(*) = 2