SELECT t.tid,o.oid from systrade_trade t LEFT JOIN systrade_order o ON t.tid = o.tid GROUP BY t.tid
如上代码,主订单表需要关联子订单表去获取详细数据,但是前端要合并展示,我们通过group去除子订单表重复数据,
SELECT count(distinct t.tid) from systrade_trade t LEFT JOIN systrade_order o ON t.tid = o.tid
再通过distinct关键字统计结果,统计语句如果加 group up 就会变成分组统计,显示多个结果,注意使用场景即可。