select p.pid, p.pname,e.visit_time
from plan p
LEFT JOIN
(SELECT e.pid,e.visit_time
from exam_info e
where e.visit_time< NOW() LIMIT 1) ei
on ei.pid=p.pid
select p.pid, p.pname,e.visit_time
from plan p
LEFT JOIN
(SELECT e.pid,e.visit_time
from exam_info e
where e.visit_time< NOW() LIMIT 1) ei
on ei.pid=p.pid