表a
agcy_id
nm
表b
id
cus_id
表c
id
agcy_id
关系
表a 1:n 表b
表a 1:n 表c
表b 与 表c 没关系
a::find()->select('*,count(cus_id) as cus_num')
->join('LEFT JOIN','b','b.cus_id=a.agcy_id')
->groupBy('cus_id');
a::find()->select('*,count(c.agcy_id) as agcy_num')
->join('LEFT JOIN','c','c.agcy_id=a.agcy_id')
->groupBy('agcy_id');
想要连接3张表,里面有a.*,cus_num,agcy_num
怎么写语句?
求解!
你可以这样写
$query=a::find();
$query->select(‘a.,b.,c.*’)