select distinct med_id code_out med_name from medical as join med_prof

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
select
distinct
m.med_id,
r.code_out,
m.med_name
from medical as m
join med_prof as p on p.med_id = m.med_id
join recode_mspec as r on (r.code_in = m.med_id and r.s_p_cod=187)
where
p.mprofil_cod in (285, 289) and
code_out > 0 and
p.mtype_cod = 273