Unknown column dans un LEFT JOIN

Résolu
Sinistrus Messages postés 1010 Date d'inscription   Statut Membre Dernière intervention   -  
Sinistrus Messages postés 1010 Date d'inscription   Statut Membre Dernière intervention   -
Bonsoir à tous,

Pouvez-vous svp m'aider à corriger ce bout de code ?
Il fonctionne très bien sauf quand je met le LEFT JOIN... ces lignes quoi
U.libelle_tag, U.libelle_fr, U.contenance_fr,
LEFT JOIN tab_produits P ON P.libelle_tag = F.libelle_tag


J'obtiens cette erreur : 1054 - Unknown column 'U.libelle_tag' in 'field list'

SELECT
U.libelle_tag, U.libelle_fr, U.contenance_fr,
F.reference, F.libelle_tag, SUM(F.quantite) AS quantite, F.prix_unitaire, SUM(F.prix_total) AS prix,
R.reference, R.point_relais, R.zone_livraison, R.date_creation, R.date_terminer, R.solde_relais, R.taux, R.etat

FROM tab_shop_facture F, tab_shop_recap R
LEFT JOIN tab_produits P ON P.libelle_tag = F.libelle_tag

WHERE 
R.reference = F.reference AND
R.zone_livraison = 'zone_p' AND
R.point_relais <> '411000-SI' AND
R.date_creation BETWEEN '2020-09-01 00:00:00' AND '2020-09-30 23:59:59' AND
(R.etat = 'RÉCUPÉRATION EN POINT RELAIS' OR R.etat = 'COMMANDE TERMINÉE')

GROUP BY 
U.libelle_tag, U.libelle_fr, U.contenance_fr,
F.reference, F.libelle_tag, F.prix_unitaire,
R.reference, R.point_relais, R.zone_livraison, R.date_creation, R.date_terminer, R.solde_relais, R.taux, R.etat


Merci de votre aide.

Configuration: Windows / Chrome 85.0.4183.102

3 réponses

  1. yg_be Messages postés 23437 Date d'inscription   Statut Contributeur Dernière intervention   Ambassadeur 1 588
     
    le LEFT JOIN n'implique pas la table F
    peut-être, au lieu de:
    FROM tab_shop_facture F, tab_shop_recap R
    LEFT JOIN tab_produits P ON P.libelle_tag = F.libelle_tag
    WHERE 
    R.reference = F.reference AND

    écrire
    FROM (tab_shop_facture F, tab_shop_recap R)
    LEFT JOIN tab_produits P ON P.libelle_tag = F.libelle_tag
    WHERE 
    R.reference = F.reference AND

    ou bien
    FROM  tab_shop_recap R, tab_shop_facture F
    LEFT JOIN tab_produits P ON P.libelle_tag = F.libelle_tag
    WHERE 
    R.reference = F.reference AND

    ou bien (qui peut donner un autre résultat)
    FROM tab_shop_facture F
    LEFT JOIN tab_shop_recap R ON R.reference = F.reference
    LEFT JOIN tab_produits P ON P.libelle_tag = F.libelle_tag
    WHERE 
    1
  2. yg_be Messages postés 23437 Date d'inscription   Statut Contributeur Dernière intervention   Ambassadeur 1 588
     
    bonjour, dans quelle table se trouve libelle_tag?
    0
    1. Sinistrus Messages postés 1010 Date d'inscription   Statut Membre Dernière intervention   17
       
      Pardon, erreur de frappe :

      SELECT
      P.libelle_tag, P.libelle_fr, P.contenance_fr,
      F.reference, F.libelle_tag, SUM(F.quantite) AS quantite, F.prix_unitaire, SUM(F.prix_total) AS prix,
      R.reference, R.point_relais, R.zone_livraison, R.date_creation, R.date_terminer, R.solde_relais, R.taux, R.etat
      
      FROM tab_shop_facture F, tab_shop_recap R
      LEFT JOIN tab_produits P ON P.libelle_tag = F.libelle_tag
      
      WHERE 
      R.reference = F.reference AND
      R.zone_livraison = 'zone_p' AND
      R.point_relais <> '411000-SI' AND
      R.date_creation BETWEEN '2020-09-01 00:00:00' AND '2020-09-30 23:59:59' AND
      (R.etat = 'RÉCUPÉRATION EN POINT RELAIS' OR R.etat = 'COMMANDE TERMINÉE')
      
      GROUP BY 
      P.libelle_tag, P.libelle_fr, P.contenance_fr,
      F.reference, F.libelle_tag, F.prix_unitaire,
      R.reference, R.point_relais, R.zone_livraison, R.date_creation, R.date_terminer, R.solde_relais, R.taux, R.etat


      Je m'étais trompé entre le P et le U (vraiment désolé)
      Voici l'erreur : 1054 Unknown column 'F.libelle_tag' in 'on clause'

      libelle_tag existe dans tab_produits et tab_shop_facture
      0
  3. Sinistrus Messages postés 1010 Date d'inscription   Statut Membre Dernière intervention   17
     
    Merci beaucoup yg_be !

    FROM (tab_shop_facture F, tab_shop_recap R)

    a fait mon bonheur !
    0