Jump to content

request for customers who bought product no longer available


ventesites

Recommended Posts

Hello

 

I am trying to get the list of customers who bought specific products no longer available

 

I got this request from the forum

 

SELECT C.email FROM ps_customer C
INNER JOIN ps_orders O on C
.id_customer = O.id_customer
INNER JOIN ps_order_detail OD on O
.id_order = OD.id_order
WHERE OD
.product_id IN (3,45,47,94,102)

 

but it works only for available product ...(available_for_order=1)

 

How can i modify the request to get the result for products no longer available, sold out? (available_for_order=0)

 

Thanks

 

Pat

Edited by ventesites (see edit history)
Link to comment
Share on other sites

I can't get the above requests to work so i tried using category

 

SELECT C.email, C.lastname, C.firstname, P.id_product, PL.name
FROM ps_customer C, ps_product_lang PL
INNER JOIN ps_orders O on C.id_customer = O.id_customer
INNER JOIN ps_order_detail OD on O.id_order = OD.id_order
INNER JOIN ps_product P on OD.product_id = P.id_product
WHERE P.available_for_order = 0
AND P.id_category_default = 2246

 

It gave me "#1054 - Unknown column 'C.id_customer' in 'on clause'...

 

what am i doing wrong?
 

Link to comment
Share on other sites

Your statement are using different table join.

 

Please try this

 

SELECT C.email, C.lastname, C.firstname, P.id_product, PL.name
FROM ps_customer C
INNER JOIN ps_orders O on C.id_customer = O.id_customer
INNER JOIN ps_order_detail OD on O.id_order = OD.id_order
INNER JOIN ps_product P on OD.product_id = P.id_product
INNER JOIN ps_product_lang PL ON PL.id_product = P.id_product
WHERE P.available_for_order = 0
AND P.id_category_default = 2246
  • 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...