select o1.vn,o1.hn,p.pname,p.fname,p.lname,o1.vstdate
,o1.icode,cast(concat(d1.name,' ',d1.strength,'#',o1.qty) as char(100)) d1
,o2.icode,cast(concat(d2.name,' ',d2.strength,'#',o2.qty) as char(100)) d2
,'OPD' type
from opitemrece o1
left join opitemrece o2 on o1.vn=o2.vn
left join drugitems d1 on o1.icode=d1.icode
left join drugitems d2 on o2.icode=d2.icode
left join patient p on o1.hn=p.hn
where o1.vstdate between '2012-1-1' and '2012-1-31'
and o1.vn is not null
and d1.name regexp 'paracet'
and d2.name regexp 'penicillin'
order by o1.hn,o1.vn
ประมาณนี้มั๊ยคับ