1oid Posted September 25, 2020 Share Posted September 25, 2020 Hey everyone, I have spotted some SQL written by @vekia and I'm trying to butcher it to pull the firstname, surname, email address and serial number from a particular product(from serial number module - haven't worked out the ID for that yet) could anyone help me understand where I am going wrong? (First time reading SQL - just spent an hour on w3schools) Quote SELECT C.email, C.firstname, C.lastname, 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 =49 Link to comment Share on other sites More sharing options...
joseantgv Posted September 26, 2020 Share Posted September 26, 2020 Remove the comma from the last SELECT attribute: SELECT C.email, C.firstname, C.lastname 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 =49 1 Link to comment Share on other sites More sharing options...
1oid Posted September 26, 2020 Author Share Posted September 26, 2020 @joseantgv such a simple fix, thank you very much! I've tried to identify the id of serial numbers attached to an order and I'm thinking it may look something like this, could I ask for a further look from you? Quote SELECT C.email, C.firstname, C.lastname, K.key_value 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_keymanager OD on O.id_order = OD.id_order WHERE OD.product_id =49 Link to comment Share on other sites More sharing options...
joseantgv Posted September 26, 2020 Share Posted September 26, 2020 (edited) This is from an external module and I don't know the tables structure. But this is wrong: K.key_value What's "K"? INNER JOIN ps_order_detail OD on O.id_order = OD.id_order INNER JOIN ps_keymanager OD on O.id_order = OD.id_order same alias "OD" for two JOINs Edited September 26, 2020 by joseantgv (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now