Jump to content

SQL query


LukaM

Recommended Posts

I stuck with SQL query. I need to get customer name, full address and email I have almost everything but can get email address:

SELECT a.`id_address`, a.`firstname` AS `firstname`, a.`lastname` AS `lastname`, `address1`, `postcode`, `city`, cl.`id_country` AS `country`, cl.`name` as country FROM `ps_address` a
LEFT JOIN `ps_country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = 8)
LEFT JOIN `ps_customer` c ON a.id_customer = c.id_customer
ORDER BY a.`id_address` ASC 

Maybe is just to late, but I can't get working code.

Link to comment
Share on other sites

hi,

 

email field is stored in ps_customer table. All you need to do is expose this field in select clause: 

SELECT c.`email`, a.`id_address`, a.`firstname` AS `firstname`, a.`lastname` AS `lastname`, `address1`, `postcode`, `city`, cl.`id_country` AS `country`, cl.`name` as country FROM `ps_address` a
LEFT JOIN `ps_country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = 8)
LEFT JOIN `ps_customer` c ON a.id_customer = c.id_customer
ORDER BY a.`id_address` ASC
  • Like 1
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...