Magento的订单相关的SQL(订单编号、创建时间、总金额、收货人、收货人地址、收货人城市、州或省(简称)、收货邮编、收货人电话、付款人邮箱)

/*
订单编号、创建时间、总金额、收货人、收货人地址、收货人城市、州或省(简称)、收货邮编、收货人电话、付款人邮箱
*/
SELECT `main_table`.increment_id, `main_table`.created_at,`main_table`.base_grand_total,`main_table`.shipping_name,
CONCAT_WS(", ",sales_flat_order_address.street,sales_flat_order_address.city,sales_flat_order_address.region) AS `ShippingAddress`,
 sales_flat_order_address.city, directory_country_region.code,sales_flat_order_address.postcode,sales_flat_order_address.telephone,
 `customer_entity`.`email` AS `customer_email`
FROM `sales_flat_order_grid` AS `main_table`
LEFT JOIN `sales_flat_order_address` ON main_table.entity_id = sales_flat_order_address.parent_id
LEFT JOIN `customer_entity` ON main_table.customer_id = customer_entity.entity_id
LEft JOIN `directory_country_region` ON directory_country_region.default_name=sales_flat_order_address.region
WHERE (sales_flat_order_address.address_type="shipping") 

你可能感兴趣的:(Magento)