对于 Wordpress/Woocommerce 网上商店,我创建了一个透视视图,显示所有订单,例如:
CREATE VIEW vwOrderPivot AS
SELECT
PM.post_id,
GROUP_CONCAT(IF(PM.meta_key = '_billing_first_name',PM.meta_value,NULL)) AS FirstName,
GROUP_CONCAT(IF(PM.meta_key = '_billing_last_name',PM.meta_value,NULL)) AS LastName,
GROUP_CONCAT(IF(PM.meta_key = '_billing_address_1',PM.meta_value,NULL)) AS Address,
GROUP_CONCAT(IF(PM.meta_key = '_billing_postcode',PM.meta_value,NULL)) AS Postcode,
GROUP_CONCAT(IF(PM.meta_key = '_billing_phone',PM.meta_value,NULL)) AS Phone,
GROUP_CONCAT(IF(PM.meta_key = '_order_total',PM.meta_value,NULL)) AS OrderTotal,
GROUP_CONCAT(IF(PM.meta_key = '_pickup_location',PM.meta_value,NULL)) AS PickupLocation,
GROUP_CONCAT(IF(PM.meta_key = '_pickup_time',PM.meta_value,NULL)) AS PickupTime,
GROUP_CONCAT(IF(PM.meta_key = '_order_items',PM.meta_value,NULL)) AS OrderItems
FROM goe_postmeta AS PM
GROUP BY PM.post_id
只有一个小问题。de OrderItems(序列化字段)中的数据仅包含 Original 字段中的一半数据。有什么办法可以解决这个问题吗?我没有线索。有人可以指出我正确的方向吗?
亲切的问候。