Php 在mysql中组合两个查询的结果
我有一张如下所示的桌子:Php 在mysql中组合两个查询的结果,php,mysql,Php,Mysql,我有一张如下所示的桌子: id friends_id 4 2 4 3 5 3 我需要此表中id值为4和5的friends_id。因此,查询必须只返回bot 4和bot 5共有的值3 friends_id 3 如何在“MYSQL”中实现这一点 但是,假设id是唯一的,您可以省略DISTINCT HAVING COUNT(*) = 2 HAVING COUNT(*) = 2
id friends_id
4 2
4 3
5 3
我需要此表中id值为4和5的friends_id。因此,查询必须只返回bot 4和bot 5共有的值3
friends_id
3
如何在“MYSQL”中实现这一点
id
是唯一的,您可以省略DISTINCT
HAVING COUNT(*) = 2
HAVING COUNT(*) = 2