最近访问5人

//我的所有日志id
select mjrzid from dede_mjrz_employee where modifydate is not null and employeeid ='575'

//找到所有查看过我的日志的员工id,姓名,阅读日期 ,包括自己了
select employeeid,name,readdate  from dede_mjrz_employee
left join dede_employee on employeeid = id
 where mjrzid in(
select mjrzid from dede_mjrz_employee where modifydate is not null and employeeid ='575'
)

//只保留读我日志的人员名字
select name from dede_mjrz_employee
left join dede_employee on employeeid = id
 where mjrzid in(
select mjrzid from dede_mjrz_employee where modifydate is not null and employeeid ='575'
) and readdate in(
    select max(readdate) from dede_mjrz_employee where readdate is not null group by employeeid
    )
order by readdate desc

 

 

你可能感兴趣的:(访问)