skyzozo Posted December 1, 2019 Share Posted December 1, 2019 (edited) Bonjour, J'ai une requête qui me permet d'afficher une liste des clients qui ont achetés tel ou tels produits, en entrant les id : SELECT distinct c.firstname,c.lastname,c.email,c.birthday FROM pre2466_customer c, pre2466_orders o, pre2466_order_detail od WHERE o.id_customer=c.id_customer AND od.id_order=o.id_order AND od.product_id in (162,163,164,166,167,169,170,171,173,176,177,178,332,334,335,336,337,338,343,344,345,350,351,352,353,355,356,448,451,471,567,568,576,577,641,642,650,657,507,442,328,331,405,406,442) Je voudrais (j'y arrive pas ...) : Avoir le numéro de téléphone fixe et portable en plus Dans : pre2466_address address Récupérer : phone phone_mobile (en plus de ma requête actuelle, de façon à avoir : Nom, prénom, email, date de naissance, tél, tél mobile) Merci pour votre aide ! Edited December 1, 2019 by skyzozo (see edit history) Link to comment Share on other sites More sharing options...
Eolia Posted December 1, 2019 Share Posted December 1, 2019 (edited) SELECT distinct od.product_id, c.firstname,c.lastname,c.email,c.birthday, a.phone, a.phone_mobile FROM pre2466_customer c INNER JOIN pre2466_orders o ON(o.id_customer = c.id_customer) INNER JOIN pre2466_order_detail od ON(od.id_order = o.id_order) INNER JOIN pre2466_address a ON(a.id_address = o.id_address_delivery) WHERE o.id_customer=c.id_customer AND od.product_id in (162,163,164,166,167,169,17..... Edited December 1, 2019 by Eolia (see edit history) Link to comment Share on other sites More sharing options...
skyzozo Posted December 1, 2019 Author Share Posted December 1, 2019 Merci du retour rapide ! Petite erreur : L'attribute "id_address" n'existe pas dans la table "pre2466_orders". Merci Link to comment Share on other sites More sharing options...
Eolia Posted December 1, 2019 Share Posted December 1, 2019 id_address_delivery pardon^^ Link to comment Share on other sites More sharing options...
skyzozo Posted December 1, 2019 Author Share Posted December 1, 2019 ÉNORME MERCI ! Pour ceux qui veulent exporter les clients ayant achetés tel ou tel produits code complet à mettre dans le gestionnaire SQL et remplacer les id par les id des produits achetés, et bien sûr changer le suffixe de la table par la votre. SELECT distinct od.product_id, c.firstname,c.lastname,c.email,c.birthday, a.phone, a.phone_mobile FROM pre2466_customer c INNER JOIN pre2466_orders o ON(o.id_customer = c.id_customer) INNER JOIN pre2466_order_detail od ON(od.id_order = o.id_order) INNER JOIN pre2466_address a ON(a.id_address = o.id_address_delivery) WHERE o.id_customer=c.id_customer AND od.product_id in (162,163,164,166,167,169,170,171,173,176,177,178,332,334,335,336,337,338,343,344,345,350,351,352,353,355,356,448,451,471,567,568,576,577,641,642,650,657,507,442,328,331,405,406,442) Bonne soirée, 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