Jointure mysql de plusieur table problem

patric1014 Messages postés 8 Date d'inscription lundi 5 juin 2006 Statut Membre Dernière intervention 21 mai 2010 - 26 mars 2010 à 18:05
Tonio_35 Messages postés 567 Date d'inscription mercredi 4 octobre 2006 Statut Membre Dernière intervention 30 août 2011 - 29 mars 2010 à 10:00
Bonjour svp j'ai un gros problem que je sais pas comment le résoudre j'ai fais une requete sql dans laquelle j'ai essai de joindre plusieur table pour afficher les enregistrement d'une table correctement donc au lieu d'avoir l'id d'un enregistrement par exemple agence = 3 de mettre le nom de l'agence donc le faire venir de la table agence donc j'ai fais cette requete

SELECT * FROM agence, bien, localisation, naturebien, pays, personne, typebien WHERE personne.idpersonne bien.personne AND naturebien.idnature  bien.nature  AND typebien.type_bien = bien.idtype AND pays.idpays = bien.pays AND  localisation.idloc  = bien.localisation  AND  agence.idagence = bien.agence ORDER BY bien.idbien


mais ca marche pas je sais pa c koi le probleme es que qlq peu m'aidé merci d'avance

4 réponses

Tonio_35 Messages postés 567 Date d'inscription mercredi 4 octobre 2006 Statut Membre Dernière intervention 30 août 2011 11
27 mars 2010 à 14:48
Hello,

Voici un cours sur les jointures que je trouve assez bien fais :

Lisez moi

Je pense que ce qui t'intéresse c'est les jointures internes (INNER JOIN)...

_________________________________
Min iPomme
0
patric1014 Messages postés 8 Date d'inscription lundi 5 juin 2006 Statut Membre Dernière intervention 21 mai 2010
29 mars 2010 à 00:38
bjr j'ai essayé de faire un truc pr évité les champ de la table vide en ajoutant un OR et IS NULL
comme ceci
"SELECT * FROM bien, personne, agence, localisation, naturebien, pays, typebien
WHERE ((personne.idpersonne = bien.personne OR bien.personne IS NULL) 
AND (agence.idagence = bien.agence OR bien.agence IS NULL) 
AND (localisation.idloc = bien.localisation OR bien.localisation IS NULL) 
AND (naturebien.idnature = bien.nature OR bien.nature IS NULL)
AND (pays.idpays = bien.pays OR bien.pays IS NULL) 
AND (typebien.idtype = bien.type_bien OR bien.type_bien IS NULL))
ORDER BY bien.idbien";

mais ca marche pas comme je le souhaite puisque il me sort deux fois le mm enregistrement donc au lieu de 2 4 enregistrement y a-t-il une personne qui peu m'aidé
merci
0
patric1014 Messages postés 8 Date d'inscription lundi 5 juin 2006 Statut Membre Dernière intervention 21 mai 2010
29 mars 2010 à 01:35
meme resultat avec ca aussi
SELECT * FROM bien
JOIN personne
ON personne.idpersonne = bien.personne 
JOIN agence
ON agence.idagence = bien.agence 
JOIN localisation
ON localisation.idloc = bien.localisation 
JOIN naturebien
ON naturebien.idnature = bien.nature 
JOIN pays
ON pays.idpays = bien.pays 
JOIN typebien
ON typebien.idtype = bien.type_bien 
ORDER BY bien.idbien



daibis
0
Tonio_35 Messages postés 567 Date d'inscription mercredi 4 octobre 2006 Statut Membre Dernière intervention 30 août 2011 11
29 mars 2010 à 10:00
INNER JOINT ?

_________________________________
Min iPomme
0
Rejoignez-nous