StringBuffer sql=new StringBuffer();
sql.append("select * from (");
sql.append(" SELECT u.id,u.userid,u.`realname` AS urealname,u.`telphone` AS utelphone,u.`viplevel`,u.`v0ctime`, ");
sql.append(" pu.`realname` AS prealname,pu.`telphone` AS ptelphone,SUM(IFNULL(up.`price`,0)) price, ");
sql.append(" (SELECT IFNULL(SUM(IFNULL(`future_price`,0)+IFNULL(`leapfrog_price`,0)),0) ");
sql.append(" FROM ss_userprice WHERE ");
sql.append(" PERIOD_DIFF( DATE_FORMAT( NOW( ) , '%Y%m' ) , DATE_FORMAT( createtime, '%Y%m' ) ) =0 ");
sql.append(" AND userid=u.id ");
sql.append(" ) yuePrice, ");
sql.append(" (SELECT COUNT(1) FROM ss_proorder WHERE po_status<>'0' AND userid=u.id) AS orderNum ");
sql.append(" FROM ss_user u ");
sql.append(" LEFT JOIN ss_user pu ON u.`refereeuserid`=pu.`userid` ");
sql.append(" LEFT JOIN ss_userprice up ON u.id=up.userid ");
sql.append(" WHERE u.viplevel <> '-1' ");
if(StrKit.notBlank(name)){
setAttr("name", name);
sql.append(" and (u.`realname` LIKE '%"+name+"%' OR u.telphone LIKE '%"+name+"%' )");
}
sql.append(" GROUP BY u.`userid`");
sql.append(" ) as mytable ");
Page<Record> page = Db.paginate(getPN(), getPS(),sql.toString());
我的项目现在的jfinul版本为2.1,不支持你说的第三个参数true的解决方案,大佬,还有别的方案可以解决吗,不想换版本,怕冲突,最好有代码示例一下,哈哈哈,谢谢啦
select * ( 原来的 sql 在此 ) as temp
用的时候:
Db.paginate(pn, ps, "select *", "from (" + 原 sql 在此 + ") as temp");