Skip to content

Is it possible to get Country Name using Select Query in Magento 2 DB?

I am trying to get the list of customers from the database directly using Mysql Query.

SELECT ce.email As Email, ce.firstname As Firstname, ce.lastname As Lastname,
COALESCE(NULLIF(cae.country_id,''), '') As Country, // here I want to show a country name like "united states", Right now it is returning country codes like "US", "Uk", etc..
COALESCE(NULLIF(cae.postcode,''), '') As Zip,
COALESCE(NULLIF(cae.telephone,''), '') As Phone
FROM customer_entity ce
LEFT JOIN customer_address_entity cae 
ON ce.entity_id = cae.parent_id and ce.default_billing = cae.entity_id

Right now, It is showing the below results and I have to show “United States” instead of “US”, Is it possible to do that? as I did not find any entry for the country name on the database.

Email Firstname Lastname Country Zip Phone
[email protected] firstname lastname US 10001 7894561230