SELECT b.*,c.* FROM ( SELECT MAX(visitDate) as date, cgid FROM crm_guest_visit GROUP BY cgid ) AS a, crm_guest_visit AS b, crm_guest AS c WHERE a.cgid = b.cgid AND a.date = b.visitDate AND a.cgid = c.id -- and c.`name`='马云'
SELECT b.*,c.* FROM ( SELECT MAX(visitDate) as date, cgid FROM crm_guest_visit GROUP BY cgid ) AS a, crm_guest_visit AS b, crm_guest AS c WHERE a.cgid = b.cgid AND a.date = b.visitDate AND a.cgid = c.id -- and c.`name`='马云'