左联子表:
LEFT JOIN ( SELECT * FROM 'order_efali` ORDER BY `id` DESC ) AS ohe ON `ohe`.`number` = `o`.`number`
TP写法:
-
- $rrc= Db::name('order_history')
- ->order('id desc')
- ->buildSql();
-
- $rsu = Db::name('order')
- ->alias('o')
- ->leftjoin('user u', 'u.id=o.user_id')
- ->leftjoin($rrc.' as ohe ', 'ohe.number=o.number')
- ->group('o.number') //去重
- ->limit($limit)
- ->page($params['page'])
- ->field('o.*,u.nickname')
- ->select();