1

I need to write a SQL query to get all countries where we have shipped al orders.

Which table has all sales order countries? I am not able to find all the countries.

0

1 Answer 1

2

From this query you can get countries of shipped orders

SELECT o.increment_id, oa.country_id FROM sales_order o
INNER JOIN sales_order_address oa ON o.entity_id=oa.parent_id
INNER JOIN sales_shipment s ON o.entity_id=s.order_id
WHERE oa.address_type='shipping'

The join for sales_order_address is to get shipping country

And the join for sales_shipment is to get the orders which are shipped.

2
  • Hi, i have written a similar query, but i am not able to country name from its country_id i have searched for tables but not able to find it
    – summu
    Commented Aug 5, 2019 at 6:02
  • 1
    You wont find it in database, it is actually in locale of core magento. If you want to get country name by it's code, then you can do it programmatically, follow this answer magento.stackexchange.com/a/159497/31910 Commented Aug 5, 2019 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.