mysql.left join 右侧表取最近日期的一条数据

mysql.left join 右侧表取最近日期的一条数据

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

posted @ 2022-01-17 15:16  codeTheWay  阅读(861)  评论(0)    收藏  举报