MySQL中条件有日期的时候正确的处理方式

 StringBuilder sql = new StringBuilder("SELECT\n" +
                "\tom.mer_id AS mer_no,\n" +
                "\tom.mer_name AS mer_name,\n" +
                "\tIFNULL( SUM( sbo.total_amount ), 0 ) AS order_amount,\n" +
                "\t(case when sbo.order_id = ''then 0 when sbo.order_id is null then 0 else count(1)end) as order_total,\n" +
                "\tomc.platform_member_id,\n" +
                "\tom.mer_addr AS mer_address,\n" +
                "\tom.contact_person,\n" +
                "\tom.contact_mobile \n" +
                "FROM\n" +
                "\to2o_merchant AS om\n" +
                "\tLEFT JOIN sdb_b2c_orders AS sbo ON sbo.merchant_bn = om.mer_id \n" +
                "\tAND FROM_UNIXTIME( createtime, '%Y-%m-%d' ) = '"+date2+"'\n" +
                "\tLEFT JOIN o2o_member_collection AS omc ON omc.mer_id = om.mer_id \n" +
                "GROUP BY\n" +
                "\tom.mer_id,\n" +
                "\tomc.platform_member_id");

MySQL中条件有日期的时候正确的处理方式_第1张图片

否则查询的结果会有失误

你可能感兴趣的:(MySQL中条件有日期的时候正确的处理方式)