1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| SELECT mi.item_id, mi.item_barcode, mi.item_pics, mi.item_name, mi.item_store, mi.item_unit, mi.item_specification, sc.item_sell_price,sc.item_original_price,sc.specs_remark, sc.item_barcode,sc.source as itemType, IF(scuh.use_type='a','1','0') use_type, scuh.purchase_num AS quantity, scuh.card_id FROM
( SELECT MAX(item_id) AS item_id FROM mall_item mi GROUP BY mi.item_barcode, mi.item_store ) tmp JOIN mall_item mi ON tmp.item_id = mi.item_id join shop_card sc on mi.item_store=sc.mall_id AND mi.item_barcode=sc.item_barcode LEFT JOIN shop_card_use_history scuh ON scuh.purchase_num>0 and scuh.use_type != 'j' and sc.card_id = scuh.card_id where scuh.shop_receipt_id = 'ps_1382892968715325440'
|