select d.icd10,d.hn ,p.pname,p.fname,p.lname ,d.vstdate, (select dt.name from opitemrece as op left outer join drugitems as dt on dt.icode = op.icode where op.icode in ('1000211') and vn= d.vn limit 1 ) as drug from ovstdiag as d left OUTER join person as p on p.patient_hn = d.hn where d.vstdate BETWEEN "2017-09-01" and "2017-09-30" and icd10 in ("A000","A001", "A009","A020","A030","A031","A032","A033","A038","A039", "A040","A041","A042","A043","A044","A045","A046","A047", "A048","A049","A050","A053","A054","A059","A080","A082", "A083","A084","A085","A09","A099","K521","K528","K529" )