select d.*,t.* ,concat('[',d.qty_name,']','[',d.orderstatus,']', d.drug_name) as drug_qty,ipt.spclty
from doctor_order_print d
left outer join tempreport t on t.reportname=d.vn and t.id=d.vn
left outer join ipt on ipt.an = d.vn
where d.vn="500004274"
order by d.print_mode,d.item_no