Petit Wapiti Posted November 16, 2014 Share Posted November 16, 2014 Bonjour je souhaite faire deux requete sql sur PS 1.5 mais je m'y connais pas assez en base sql pour le faire seul : - extraire mes commandes mais avec le détails de la commande (c'est a dire que je voudrais aussi extraire l'id et les noms des produits achetés J'ai cette commande sql mais manque détails produit (ID et nom) : SELECT o.`id_order` AS `id`, CONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) AS `Customer`, ca.`name` AS `Carrier`, cu.`name` AS `Currency`, o.`payment`, CONCAT(o.`total_paid_real`, ' ', cu.`sign`) AS `Total`, o.`date_add` AS `Date` FROM `ps_orders` o LEFT JOIN `ps_customer` c ON (o.`id_customer` = c.`id_customer`) LEFT JOIN `ps_carrier` ca ON (o.id_carrier = ca.id_carrier) LEFT JOIN `ps_currency` cu ON (o.`id_currency` = cu.`id_currency`) - extraire le nombre de commande pour tout les id produit Merci d'avance. Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted November 17, 2014 Share Posted November 17, 2014 SELECT o.`id_order` AS `id`, CONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) AS `Customer`, ca.`name` AS `Carrier`, cu.`name` AS `Currency`, o.`payment`, CONCAT(o.`total_paid_real`, ' ', cu.`sign`) AS `Total`, o.`date_add` AS `Date`, od.`product_id`, od.`product_name` FROM `ps_orders` o LEFT JOIN `ps_customer` c ON (o.`id_customer` = c.`id_customer`) LEFT JOIN `ps_carrier` ca ON (o.id_carrier = ca.id_carrier) LEFT JOIN `ps_currency` cu ON (o.`id_currency` = cu.`id_currency`) LEFT JOIN `ps_order_detail` od ON (o.`id_order` = od.`id_order`) Link to comment Share on other sites More sharing options...
Petit Wapiti Posted December 22, 2014 Author Share Posted December 22, 2014 J'avais oublier de vous remercier c'est parfait. Par contre comment choisir que les commandes qui dates de 2014 (c'est a dire a partir du 01.01.2014) Merci encore Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted December 23, 2014 Share Posted December 23, 2014 SELECT o.`id_order` AS `id`, CONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) AS `Customer`, ca.`name` AS `Carrier`, cu.`name` AS `Currency`, o.`payment`, CONCAT(o.`total_paid_real`, ' ', cu.`sign`) AS `Total`, o.`date_add` AS `Date`, od.`product_id`, od.`product_name` FROM `ps_orders` o LEFT JOIN `ps_customer` c ON (o.`id_customer` = c.`id_customer`) LEFT JOIN `ps_carrier` ca ON (o.id_carrier = ca.id_carrier) LEFT JOIN `ps_currency` cu ON (o.`id_currency` = cu.`id_currency`) LEFT JOIN `ps_order_detail` od ON (o.`id_order` = od.`id_order`) WHERE o.`date_add`>'2014-01-01 00:00:00' Je ne l'ai pas testée. Link to comment Share on other sites More sharing options...
Locapansa Posted September 21, 2017 Share Posted September 21, 2017 Bonjour, Merci beaucoup Olivier pour cette query elle répond presque totalement à mon besoin et je ne parvenais pas à l'écrire Serait il possible d'ajouter le n° d'attribut à cette requête ? Merci d'avance Link to comment Share on other sites More sharing options...
Locapansa Posted September 25, 2017 Share Posted September 25, 2017 Bonjour à tous, Si quelqu'un pouvait m'aider à ajouter l' attribute_id à la requête ci-dessous ça m'aiderait énormément à sortir des stats de ventes...... Merci d'avance SELECT o.`id_order` AS `id`,CONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) AS `Customer`,ca.`name` AS `Carrier`,cu.`name` AS `Currency`,o.`payment`, CONCAT(o.`total_paid_real`, ' ', cu.`sign`) AS `Total`,o.`date_add` AS `Date`,od.`product_id`, od.`product_name`FROM `ps_orders` oLEFT JOIN `ps_customer` c ON (o.`id_customer` = c.`id_customer`)LEFT JOIN `ps_carrier` ca ON (o.id_carrier = ca.id_carrier)LEFT JOIN `ps_currency` cu ON (o.`id_currency` = cu.`id_currency`)LEFT JOIN `ps_order_detail` od ON (o.`id_order` = od.`id_order`)WHERE o.`date_add`>'2014-01-01 00:00:00' Link to comment Share on other sites More sharing options...
LauraPresta Posted February 22, 2018 Share Posted February 22, 2018 (edited) J'ai bien fouillé mais je n'ai pas trouvé... à quoi correspond ca. cu. o. od. etc.. devant les colonnes ? On dirait que c'est lié à prestashop uniquement ou je me trompe ? Edited February 22, 2018 by LauraPresta (see edit history) Link to comment Share on other sites More sharing options...
BeComWeb Posted February 23, 2018 Share Posted February 23, 2018 (edited) Ce sont les alias des tables : voir ici Edited February 23, 2018 by BeComWeb piaf (see edit history) Link to comment Share on other sites More sharing options...
Heathcliff Posted March 23, 2018 Share Posted March 23, 2018 Bonjour, je me joint à la discussion, que devrais-je ajouter à la requête pour obtenir en plus l'adresse des clients ? merci beaucoup !! Link to comment Share on other sites More sharing options...
EUKALYPTE Posted December 20, 2018 Share Posted December 20, 2018 Bonjour, Je pensais avoir trouvé mon bonheur dans cette discussion... mais la requête ne fonctionne pas dans Prestashop 1.7. Est il possible d'avoir un update ? Merci ! 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