->alias('b') ->field(['(b.order_amount + b.store_amount) as total','b.create_time','b.order_id','b.pay_types']) ->where("b.order_status = 2") ->union(['select pay_amount as total,create_time,recharge_id as order_id,pay_type as pay_types from tp_recharge']) ->buildSql();
如上 执行之后 sql 语句为
SELECT (b.order_amount + b.store_amount) astotal,`b`.`create_time`,`b`.`order_id`,`b`.`pay_types` FROM `tp_order` `b` UNION ( select pay_amount as total,create_time,recharge_id as order_id,pay_type as pay_types from tp_recharge ) WHERE ( b.order_status = 2 )
where 条件放到最后执行了,我想要的是 把where 条件查询第一个表的后面,请问大家如何解决这个问题的
忽然笑