thinkphp3.2.3
有两张表,
shop表中有 id,name字段
shop_period表中有 sid字段
shop的id 就是 shop_period的sid
想要统计shop_period 里sid出现的次数,然后关联shop表
大神,这样要怎么操作,是用join还是用table,怎么用,谢谢
M('shop')->join('a left join __SHOP_PERIOD__ b on a.id = b.sid')->field('a.*,count(b.sid)')->select();
打印的数据应该是这样的
Array ( [0] => Array ( [id] => 1 [count(b.item_id)] => 25 ) )