我刚刚开始学习mysql for php!我在查询mysql从表中获取数据团队时遇到了问题,我有一个带有字段表名( team )的表。
id, OPPONENT, COMPETITION
数据表(团队)如下
**id** **OPPONENT** **COMPETITION**
1 barcelona real madrid
2 barcelona Villarreal
3 real madrid ruby
我想要写查询得到这样的表
**team**
barcelona
下面是这个查询(MySQL语法):
select
id_image
from
(
select
id_image
, count(id_image) as nb
from
data
group by
id_image
) temp_table
where
nb = (select count(distinct id_group) from data)
数据表由3列组成: int id_user、int id_group和int id_image。
行(x,y,z)意味着:
图像z在图像组y中。