Jump to content

MySQL query to print address list


Øyvind

Recommended Posts

My shipping company requires me to upload an Excel sheet with addresses when I order shipping for a batch of orders.

The format they require is:

Firstname Lastname | Postcode | Address 1 | Mobile phone | Email

I use this MySQL query to get firstname lastname, postcode, address 1 and mobile phone:

SELECT CONCAT(firstname, ' ', lastname) as firstlast, postcode, address1, phone_mobile 
FROM `ps_address` 
INNER JOIN ps_orders ON ps_orders.id_address_delivery=ps_address.id_address 
WHERE current_state = 2 

The only problem is that email is missing. I assume I have to include the "email" from ps_customer, but how do I make it into one query?

Link to comment
Share on other sites

Found it out myself:

SELECT CONCAT(ps_address.firstname, ' ', ps_address.lastname) as firstlast, ps_address.postcode, ps_address.address1, ps_address.phone_mobile, ps_customer.email 
FROM ps_address 
INNER JOIN ps_customer ON ps_customer.id_customer=ps_address.id_customer 
INNER JOIN ps_orders ON ps_orders.id_address_delivery=ps_address.id_address 
WHERE current_state = 2 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...