我有三张桌子
CV表
-------------
id name
-------------
1 Arthur
2 James
3 John
4 king技术表
-------------
id name
-------------
1 Java
2 C#
3 PHP
4 Python桥
-----------------
CV_id tech_id
-----------------
1 1
1 2
1 3
1 4
2 1
3 2
3 4
4 2
4 1我希望在寻找与tech.id=1和tech.id=2相关的“cv”时,结果是这样的
结果
-----------------
Arthur
king而不是结果:
结果
-----------------
Arthur
James
king
John就像在说:
- CV00 --> Java, PHP
- CV01 --> Java, C#
- CV02 --> PHP, Django我想要技术人员: CV00,而不是CV01和CV02。
发布于 2019-02-18 11:35:32
您可以根据您要查找的集合中的值的子查询和与2值匹配的值使用连接。
select name
from cv_table c
inner join (
select distinct b.CV_id
from bridge b
where b.tech_id in (1,2)
group by CV_id
having count(distinct tech_id) = 2
) t on t.CV_id = c.idhttps://stackoverflow.com/questions/54746047
复制相似问题