jdepluvie Posted September 27, 2021 Share Posted September 27, 2021 Bonjour, Je cherche à extraire les client d'un département précis pour des raisons marketing. J'utilise cette requête, mais les résultats ne sont pas bons, sur le s5 première lignes testées en résultat, la moitié ne sont pas bons. L'idée est d'extraire pour les commandes passées le code postal le téléphone et l'email du client, ces informations étant extraite de 3 tables différentes. SELECT DISTINCT PA.postcode, PO.id_order, PC.email, PA.phone, PA.phone_mobile from ps_orders PO, ps_customer PC, ps_address PA WHERE PO.id_customer = PC.id_customer and PA.id_customer = PO.id_customer and PA.postcode like "53%"; Quelle condition manque t il pour disposer d'une extraction correcte ? Merci par avance Link to comment Share on other sites More sharing options...
Shonen Posted September 28, 2021 Share Posted September 28, 2021 (edited) Essaye plutôt avec des jointures https://sql.sh/cours/jointures/left-join SELECT DISTINCT PA.postcode, PO.id_order, PC.email, PA.phone, PA.phone_mobile FROM ps_orders PO LEFT JOIN ps_customer PC ON PO.id_customer = PC.id_customer LEFT JOIN ps_address PA ON PC.id_customer = PA.id_customer WHERE PA.postcode like "53%"; Edited September 28, 2021 by Shonen (see edit history) Link to comment Share on other sites More sharing options...
jdepluvie Posted October 19, 2021 Author Share Posted October 19, 2021 Bonjour, Merci ca fonctionne. J'arrive à faire des requêtes simple, mais les jointures je dois faire un blocage.... Merci Link to comment Share on other sites More sharing options...
Mediacom87 Posted October 19, 2021 Share Posted October 19, 2021 Il y a 1 heure, jdepluvie a dit : mais les jointures je dois faire un blocage Une aide pour comprendre https://sql.sh/cours/jointures 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