Mysql-CONCAT和GROUP_CONCAT组合使用场景
2021/12/23 19:07:29
本文主要是介绍Mysql-CONCAT和GROUP_CONCAT组合使用场景,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
拼接一个头明细信息
甚至可以直接把结果,转为实体或者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
这篇关于Mysql-CONCAT和GROUP_CONCAT组合使用场景的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-18Mysql安装入门:新手必读指南
- 2024-11-18MySQL事务MVCC原理入门详解
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-15MySQL教程:初学者必备的MySQL数据库入门指南
- 2024-11-15MySQL教程:初学者必看的MySQL入门指南
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南
- 2024-11-02初学者指南:部署MySQL集群资料