if(($startdate!="") && ($enddate!="")) $strSql_Condition.=" and eb_limitdate >= to_date('$startdate','YYYY/MM/DD') and eb_limitdate <= to_date('$enddate','YYYY/MM/DD')"; $sql="SELECT c_id, if(ee_limitdate>eb_limitdate, ee_limitdate, eb_limitdate) endtime FROM escustomers_base LEFT JOIN escustomers_extend ON $strSql_Condition group by c_id HAVING =MAX(ee_limitdate)";然后执行sql就可以了。c_id是你的客户编号
$strSql_Condition.=" and eb_limitdate >= to_date('$startdate','YYYY/MM/DD') and eb_limitdate <= to_date('$enddate','YYYY/MM/DD')";
$sql="SELECT c_id, if(ee_limitdate>eb_limitdate, ee_limitdate, eb_limitdate) endtime
FROM escustomers_base
LEFT JOIN escustomers_extend ON $strSql_Condition
group by c_id
HAVING =MAX(ee_limitdate)";然后执行sql就可以了。c_id是你的客户编号
不知道你用什么数据库!