根据查询的结果, 除了这2个字段别的字段都相同。那么能不能整合成一条数据呢?当然是可以的。用到 mysql的关键字
GROUP_CONCAT
1 select q.barcode,q.PATIENTNO,q.PATIENTNAME,q.PATIENTSEX,q.PATIENTAGE,q.PATIENTTYPE
2 ,q.SAMPLETIME,q.SAMPLETYPE,q.DOCTORDEPTID,q.DOCTORDEPTNAME
3 ,q.DOCTORNAME,q.MEMO
4 , GROUP_CONCAT(q.his_itemcode SEPARATOR ',') his_itemcode ,GROUP_CONCAT(q.his_itemname SEPARATOR ',') his_itemname,ss.code,ss.name,ssr.stock_bin_code,ssb.name
5 from lis_queue_reg q
6 join sampling_setting ss on ss.active =1
7 join sampling_setting_rel ssr on ssr.setting_code = ss.code and q.his_itemcode = ssr.item_code
8 join sampling_stock_bin ssb on ssb.code = ssr.stock_bin_code
9 WHERE q.PATIENTNAME='钟敏' and BARCODE='1002982470'
结果如下