select d1.*,v1.*,o1.*,concat(d.name," ",d.strength," ",d.units) as drugname
from doctor_order_print d1
left outer join vn_stat v1 on v1.vn=d1.vn
left outer join ovst o1 on o1.vn=d1.vn
left outer join s_drugitems d on d.icode=d1.icode
where d1.vn="530118091223" and d1.print_server="OPD" and d1.print_status='N' and qty_name > 0
order by doctor_order_print_code