在所有组织sql中显示全名医生

时间:2018-12-12 11:44:27

标签: sql many-to-many

如何更改全名的doc-id?

select w.id,w.doc,w.org
from workplaces w join
     orgs o
     on o.id=w.org     
--where o.active=1 and o.cst='NY' and w.active=1 and w.cst='NY'(table have -     
history, and active=1-it is actual record)     
order by w.org    

er-model

example display

1 个答案:

答案 0 :(得分:0)

检查此。您需要为JOIN表添加另一个doctors

SELECT
    o.name OrgName
    w.id        
   ,d.name_f +' '+d.name_s DoctorFullName
   ,d.name_p
   ,w.org
FROM workplaces w
JOIN orgs o ON o.id = w.org     
JOIN doctors d ON d.id = w.doc
order by w.org