甚至可以直接把结果,转为实体或者xml或者json进行传输。
字符串的操作
SELECT XBLNR, BUDAT, BLDAT, ZYKNR, UMWRK, UMLGO, WERKS, LGORT, CONCAT( '[', GROUP_CONCAT( CONCAT( '{"MATNR":"', IFNULL(MATNR, ''), '","ZYKNN":"', ZYKNN, '","ERFME":"', ERFME, '","ERFMG":', IFNULL(ERFMG, 0), '}' ) SEPARATOR ',' ), ']' ) ITEM FROM ( SELECT pod.purchaseOrderHeaderCode XBLNR, DATE_FORMAT(NOW(), '%Y%m%d') BUDAT, DATE_FORMAT(NOW(), '%Y%m%d') BLDAT, pod.sapPurchaseOrderCode ZYKNR, pod.sapFactory UMWRK, pod.sapWarehouseCode UMLGO, poh.sapOutFactoryCode WERKS, poh.sapOutWarehouseCode LGORT, pod.skuCode MATNR, pod.sapPurchaseOrderLineCode ZYKNN, IFNULL(pod.sapUnit, sku.orderUnit) ERFME, CASE IFNULL(pod.sapUnit, sku.orderUnit) WHEN sku.orderUnit THEN pod.receiptQty ELSE pod.receiptQty * IFNULL(sku.basicUnitNumerator, 1) / IFNULL(sku.basicUnitDenominator, 1) END ERFMG FROM purchase_order_detail pod INNER JOIN purchase_order_header poh ON poh.id = pod.purchaseOrderHeaderId INNER JOIN SKU ON sku.`code` = pod.skuCode AND poh.companyCode = sku.companyCode AND pod.receiptQty > 0 WHERE pod.purchaseOrderHeaderId =:id ) A GROUP BY XBLNR, ZYKNR, UMWRK, UMLGO