有两个表tb1和tb2tb1tid operator typecode
1 a -7
1 b -7
1 a -7
1 b -7
1 b 2tb2
tid tname
1 Chelsea
2 Man U我现在想tb2.tid和tb1.tid是关联的 (codeid=-7是定死的)
我现在想得到
Chelsea 2 a
Chelsea 2 b的结果如何做呢?谢谢
1 a -7
1 b -7
1 a -7
1 b -7
1 b 2tb2
tid tname
1 Chelsea
2 Man U我现在想tb2.tid和tb1.tid是关联的 (codeid=-7是定死的)
我现在想得到
Chelsea 2 a
Chelsea 2 b的结果如何做呢?谢谢
tb2.tname,count(*) as cnt,
tb1.operator
from tb1,tb2
where tb1.tid=tb2.tid
and tb1.typecode=-7
group by
tb2.tname,
tb1.operator
where a.typecode=-7
gourp by b.tname,a.operator