Jump to content

Requête Gestionnaire SQL


Recommended Posts

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 by skyzozo (see edit history)
Link to comment
Share on other sites

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 by Eolia (see edit history)
Link to comment
Share on other sites

É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

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...