AI Reports

Guides › Database reference › Orders and sales

Magento 2 sales_order_address table

The billing and shipping address of each order, copied at checkout, so later changes to a customer's address book don't change past orders.

Key columns

ColumnWhat it means
entity_idInternal address ID.
parent_idThe order, linking to sales_order.entity_id.
address_typebilling or shipping.
firstname / lastname / companyThe name on the address.
streetThe street lines, separated by a new line.
city / region / postcodeTown, state or county name, and postcode.
country_idTwo-letter country code, such as GB or US.
customer_address_idThe address book entry it came from, if any.

Good to know

Example: Orders per shipping country, last 30 days

Works on Magento Open Source and Adobe Commerce.

SELECT a.country_id, COUNT(*) AS orders
FROM sales_order o
JOIN sales_order_address a ON a.parent_id = o.entity_id AND a.address_type = 'shipping'
WHERE o.created_at >= NOW() - INTERVAL 30 DAY
GROUP BY a.country_id
ORDER BY orders DESC;

Tested on Magento Open Source and Adobe Commerce 2.4.8. Read-only. If your tables have a prefix, add it to each table name.

Extra columns on Adobe Commerce

Adobe Commerce has 27 columns here instead of 26. The extra ones come from these Commerce features:

Foreign keys

All 26 columns (Magento Open Source)

Show all columns
ColumnTypeCan be emptyMagento's description
entity_idint(10) unsignedEntity ID
parent_idint(10) unsignedyesParent ID
customer_address_idint(11)yesCustomer Address ID
quote_address_idint(11)yesQuote Address ID
region_idint(11)yesRegion ID
customer_idint(11)yesCustomer ID
faxvarchar(255)yesFax
regionvarchar(255)yesRegion
postcodevarchar(255)yesPostcode
lastnamevarchar(255)yesLastname
streetvarchar(255)yesStreet
cityvarchar(255)yesCity
emailvarchar(255)yesEmail
telephonevarchar(255)yesPhone Number
country_idvarchar(2)yesCountry ID
firstnamevarchar(255)yesFirstname
address_typevarchar(255)yesAddress Type
prefixvarchar(255)yesPrefix
middlenamevarchar(255)yesMiddlename
suffixvarchar(255)yesSuffix
companyvarchar(255)yesCompany
vat_idtextyesVat ID
vat_is_validsmallint(6)yesVat Is Valid
vat_request_idtextyesVat Request ID
vat_request_datetextyesVat Request Date
vat_request_successsmallint(6)yesVat Request Success

Related tables

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn