Two JsonArray are merged into a JsonArray based on the same attribute

< H2 > JsonArray 1: < / H2 >
[{
                "purchase_data_id": "1",
                "line_number": "1",
                "warehouse_id": "14",
                "product_id": "1723",
                "sku_id": "28189",
                "barcode": "",
                "expect_qty": "1",
                "actual_qty": "0",
                "purchase_price": "0.1",
                "total_purchase_price": "0.0000",
                "remark": "",
                "updated_at": "0000-00-00 00:00:00",
                "product_img": "http:\/\/easy.ezhangxiu.com\/resource\/img\/common\/default_s.jpg",
                "product_name": "",
                "product_code": "ceshi123",
                "unit_name": "",
                "expect_qty_name": "1",
                "unit_convert_name": "",
                "big_unit_name": "",
                "unit_convert": "0",
                "sku_code": "1234567",
                "sku_str": ": "
            },
            {
                "purchase_data_id": "2",
                "line_number": "2",
                "warehouse_id": "14",
                "product_id": "1723",
                "sku_id": "28191",
                "barcode": "",
                "expect_qty": "1",
                "actual_qty": "0",
                "purchase_price": "0.1",
                "total_purchase_price": "0.0000",
                "remark": "",
                "updated_at": "0000-00-00 00:00:00",
                "product_img": "http:\/\/easy.ezhangxiu.com\/resource\/img\/common\/default_s.jpg",
                "product_name": "",
                "product_code": "ceshi123",
                "unit_name": "",
                "expect_qty_name": "1",
                "unit_convert_name": "",
                "big_unit_name": "",
                "unit_convert": "0",
                "sku_code": "12345678",
                "sku_str": ": "
            }]
< H2 > JsonArray2 < / H2 >
[{
            "order_sn": "D-20180926-00586",
            "order_product_id": "681",
            "supplier_id": "207",
            "product_id": "1723",
            "sku_id": "28189",
            "quantity": "1",
            "product_name": "",
            "cancel_quantity": "0.000",
            "real_quantity": "1",
            "apply_return_quantity": "0",
            "return_quantity": "0",
            "lack_quantity": "0",
            "selling_price": "0.08",
            "price_type": "1",
            "discount_amount": "0",
            "promotion_amount": "0",
            "coupon_amount": "0",
            "sku_info": {
                "sku_id": "28189",
                "sku_name": "",
                "sku_text": "",
                "sku_code": "1234567",
                "barcode": "",
                "unit_name": "",
                "weight": "1.00"
            },
            "is_gift": "0",
            "remarks": "",
            "created_at": "2018-09-26 10:52:52",
            "created_by": "",
            "updated_at": "2018-09-26 10:52:52",
            "updated_by": "",
            "shipment_quantity": "1",
            "pic": "http:\/\/qiniu.image.ezhangxiu.com\/attach\/69\/207\/201809\/1d\/43\/1dd27977a5a38e8bde0fe5a8c0811043.jpg_160x160xz.jpg"
        },
        {
            "order_sn": "D-20180926-00586",
            "order_product_id": "682",
            "supplier_id": "207",
            "product_id": "1723",
            "sku_id": "28191",
            "quantity": "1",
            "product_name": "",
            "cancel_quantity": "0.000",
            "real_quantity": "1",
            "apply_return_quantity": "0",
            "return_quantity": "0",
            "lack_quantity": "0",
            "selling_price": "0.08",
            "price_type": "1",
            "discount_amount": "0",
            "promotion_amount": "0",
            "coupon_amount": "0",
            "sku_info": {
                "sku_id": "28191",
                "sku_name": "",
                "sku_text": "",
                "sku_code": "12345678",
                "barcode": "",
                "unit_name": "",
                "weight": "1.00"
            },
            "is_gift": "0",
            "remarks": "",
            "created_at": "2018-09-26 10:52:52",
            "created_by": "",
            "updated_at": "2018-09-26 10:52:52",
            "updated_by": "",
            "shipment_quantity": "1",
            "pic": "http:\/\/qiniu.image.ezhangxiu.com\/attach\/69\/207\/201809\/1d\/43\/1dd27977a5a38e8bde0fe5a8c0811043.jpg_160x160xz.jpg"
        }]

product_id of JsonArray 1 is equal to order_product_id of JsonArray 2

merge these two attributes into one jsonarray

[{
            "order_sn": "D-20180926-00586",
            "order_product_id": "681",
            "supplier_id": "207",
            "product_id": "1723",
            "sku_id": "28189",
            "quantity": "1",
            "product_name": "",
            "cancel_quantity": "0.000",
            "real_quantity": "1",
            "apply_return_quantity": "0",
            "return_quantity": "0",
            "lack_quantity": "0",
            "selling_price": "0.08",
            "price_type": "1",
            "discount_amount": "0",
            "promotion_amount": "0",
            "coupon_amount": "0",
            "sku_info": {
                "sku_id": "28189",
                "sku_name": "",
                "sku_text": "",
                "sku_code": "1234567",
                "barcode": "",
                "unit_name": "",
                "weight": "1.00"
            },
            "is_gift": "0",
            "remarks": "",
            "created_at": "2018-09-26 10:52:52",
            "created_by": "",
            "updated_at": "2018-09-26 10:52:52",
            "updated_by": "",
            "shipment_quantity": "1",
            "pic": "http:\/\/qiniu.image.ezhangxiu.com\/attach\/69\/207\/201809\/1d\/43\/1dd27977a5a38e8bde0fe5a8c0811043.jpg_160x160xz.jpg"
                "purchase_data_id": "1",
                "line_number": "1",
                "warehouse_id": "14",
                "product_id": "1723",
                "sku_id": "28189",
                "barcode": "",
                "expect_qty": "1",
                "actual_qty": "0",
                "purchase_price": "0.1",
                "total_purchase_price": "0.0000",
                "remark": "",
                "updated_at": "0000-00-00 00:00:00",
                "product_img": "http:\/\/easy.ezhangxiu.com\/resource\/img\/common\/default_s.jpg",
                "product_name": "",
                "product_code": "ceshi123",
                "unit_name": "",
                "expect_qty_name": "1",
                "unit_convert_name": "",
                "big_unit_name": "",
                "unit_convert": "0",
                "sku_code": "1234567",
                "sku_str": ": "
            },
            {
            "order_sn": "D-20180926-00586",
            "order_product_id": "682",
            "supplier_id": "207",
            "product_id": "1723",
            "sku_id": "28191",
            "quantity": "1",
            "product_name": "",
            "cancel_quantity": "0.000",
            "real_quantity": "1",
            "apply_return_quantity": "0",
            "return_quantity": "0",
            "lack_quantity": "0",
            "selling_price": "0.08",
            "price_type": "1",
            "discount_amount": "0",
            "promotion_amount": "0",
            "coupon_amount": "0",
            "sku_info": {
                "sku_id": "28191",
                "sku_name": "",
                "sku_text": "",
                "sku_code": "12345678",
                "barcode": "",
                "unit_name": "",
                "weight": "1.00"
            },
            "is_gift": "0",
            "remarks": "",
            "created_at": "2018-09-26 10:52:52",
            "created_by": "",
            "updated_at": "2018-09-26 10:52:52",
            "updated_by": "",
            "shipment_quantity": "1",
            "pic": "http:\/\/qiniu.image.ezhangxiu.com\/attach\/69\/207\/201809\/1d\/43\/1dd27977a5a38e8bde0fe5a8c0811043.jpg_160x160xz.jpg"
                "purchase_data_id": "2",
                "line_number": "2",
                "warehouse_id": "14",
                "product_id": "1723",
                "sku_id": "28191",
                "barcode": "",
                "expect_qty": "1",
                "actual_qty": "0",
                "purchase_price": "0.1",
                "total_purchase_price": "0.0000",
                "remark": "",
                "updated_at": "0000-00-00 00:00:00",
                "product_img": "http:\/\/easy.ezhangxiu.com\/resource\/img\/common\/default_s.jpg",
                "product_name": "",
                "product_code": "ceshi123",
                "unit_name": "",
                "expect_qty_name": "1",
                "unit_convert_name": "",
                "big_unit_name": "",
                "unit_convert": "0",
                "sku_code": "12345678",
                "sku_str": ": "
            }]
Jul.16,2021

double for loop, $. Learn about
in addition, it is best to regenerate the array, and not change the original data

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaafe6-46a9f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaafe6-46a9f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?