用select * from timesheets as t,project_staff as p_s,projects as p where p_s.project_no=p.project_no and t.project_staff=p_s.projet_staff and p.project_mannger='user001';查询user0001管理下的所有项目下的所有成员写的所有的timesheets
用select * from timesheets where project_staff='user001'就得到他的timesheet啦

解决方案 »

  1.   

    select t.* from 
             timesheets as t,
             project_staff as p_s,
             projects as p 
      where  ( p_s.project_no=p.project_no 
              and t.project_staff=p_s.projet_staff 
              and p.project_mannger='user001' )
              or t.project_staff='user001';
      

  2.   


    select t.* 
    from 
             timesheets as t 
             left join project_staff as ps on t.project_staff = ps.project_staff 
             left join projects as p on ps.project_no = p.project_no
    where  p.project_mannger='user001' or t.project_staff='user001'