Php mysql-计算两个变量的总条目数
我明白了Php mysql-计算两个变量的总条目数,php,mysql,database,Php,Mysql,Database,我明白了 select county, count(county) as total_entry from house group by county; 现在我想得到以下结果: county | total_entry 'county1'| '1' 'county2'| '11' 'county3'| '2' 我如何做到这一点?(ad_类型是内部表中的字段) 试试这样的方法:(我假设你的总数是关闭的,因为你也想按广告类型分组) 选择县,将(县)计数为县,从房屋中键入 按县分组,ad_类型
select county, count(county) as total_entry from house
group by county;
现在我想得到以下结果:
county | total_entry
'county1'| '1'
'county2'| '11'
'county3'| '2'
我如何做到这一点?(ad_类型是内部表中的字段) 试试这样的方法:(我假设你的总数是关闭的,因为你也想按广告类型分组)
选择县,将(县)计数为县,从房屋中键入
按县分组,ad_类型
thx!!作品只需使用逗号而不是“&”来实现GROUPBY。
county | ad_type | total_entries
'county1'| SALE | '1'
'county2'| SALE | '4'
'county2'| RENT | '5'
'county2'| NEWHOUSING | '2'
'county3'| RENT | '2'