select cp.comp_cn,cp.comp_address,cp.comp_tel,oper.name_cn,dd.tihuo_man from diaodu dd join company cp on dd.comp_id=cp.comp_id join agent_staff ast on cp.comp_id=ast.comp_id join operator oper on ast.oper_id=oper.oper_id

解决方案 »

  1.   

     select c.comp_cn,c.comp_address,c.comp_tel,o.name_cn,d.tihuo_man 
       from diaodu d left join company c on c.comp_id = d.comp_id 
       left join agent_staff a on a.comp_id = d.comp_id and a.re = '市场负责人' 
       left join operator o on o.oper_id = a.oper_id
      

  2.   

    建个视图想怎么查就怎么查
    create view  xxxxxxxxxxx
    as
    select  xXXX
    from  diaodu a left join company b
             on a.comp_id=b.comp_id
          left join agent_staff c
             on b.comp_id=c.comp_id
          left join operator d
             on d.oper_id=c.oper_id