求一条sql语句,自己搞糊涂了
tDictProvince(省表)
-------------------------
iProvId
vcProvName
tDictCity(市表)
-------------------------
iCityId
iProvId
vcCityName
tProduct(产品表)
-------------------------
id
vcproductname
iCityId
iProvId
--------------------------------
结果
省名称 市名称 产品数量
? ? ?
--------------------------------
------解决方案----------------------试试
select _p.vcProvName,_c.vcCityName,count(1) as 产品数量
from tProduct _m
join tDictProvince _p on _p.iProvId = _m.iProvId
join tDictCity _c on _c.iCityId = _m.iCityId
group by _p.vcProvName,_c.vcCityName