<!-- 昨天的退换订单总数 -->
<select id="findYesterdayOrderRefundCount" resultType="java.lang.Integer">
select
ifnull(sum(count),0) count
from(
select count(1) as count from
car_wash_order WHERE resund_state >1 and
TO_DAYS( NOW( ) ) - TO_DAYS(refund_time)=1
UNION
all
select count(1) as
count
from car_rescue WHERE
TO_DAYS( NOW( ) ) - TO_DAYS(refund_time)=1
UNION all
select
count(1)
as count
from car_refund
WHERE TO_DAYS( NOW( ) ) - TO_DAYS(refund_time)=1
) t
</select>
注解:TO_DAYS( NOW( ) ) - TO_DAYS(refund_time)=1
这个代表是昨天的 refund_time这个代表的是你要查询的时间字段
将三张表的count查出来相加 ,如果为空就赋值0 ifnull(sum(count),0)