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
| Column | What it means |
|---|---|
entity_id | Internal address ID. |
parent_id | The order, linking to sales_order.entity_id. |
address_type | billing or shipping. |
firstname / lastname / company | The name on the address. |
street | The street lines, separated by a new line. |
city / region / postcode | Town, state or county name, and postcode. |
country_id | Two-letter country code, such as GB or US. |
customer_address_id | The address book entry it came from, if any. |
Good to know
- Orders with only virtual or downloadable products have a billing address but no shipping address.
- The order also stores
billing_address_idandshipping_address_id, pointing at these rows.
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:
- Gift Registry:
giftregistry_item_id
Foreign keys
parent_id→ sales_order.entity_id
All 26 columns (Magento Open Source)
Show all columns
| Column | Type | Can be empty | Magento's description |
|---|---|---|---|
entity_id | int(10) unsigned | Entity ID | |
parent_id | int(10) unsigned | yes | Parent ID |
customer_address_id | int(11) | yes | Customer Address ID |
quote_address_id | int(11) | yes | Quote Address ID |
region_id | int(11) | yes | Region ID |
customer_id | int(11) | yes | Customer ID |
fax | varchar(255) | yes | Fax |
region | varchar(255) | yes | Region |
postcode | varchar(255) | yes | Postcode |
lastname | varchar(255) | yes | Lastname |
street | varchar(255) | yes | Street |
city | varchar(255) | yes | City |
email | varchar(255) | yes | |
telephone | varchar(255) | yes | Phone Number |
country_id | varchar(2) | yes | Country ID |
firstname | varchar(255) | yes | Firstname |
address_type | varchar(255) | yes | Address Type |
prefix | varchar(255) | yes | Prefix |
middlename | varchar(255) | yes | Middlename |
suffix | varchar(255) | yes | Suffix |
company | varchar(255) | yes | Company |
vat_id | text | yes | Vat ID |
vat_is_valid | smallint(6) | yes | Vat Is Valid |
vat_request_id | text | yes | Vat Request ID |
vat_request_date | text | yes | Vat Request Date |
vat_request_success | smallint(6) | yes | Vat Request Success |