1 pièce(s) jointe(s)
Doublons dans une requête
Bonjour,
Je reviens vers vous pour le même projet mais pour un autre problème.
Ma première page envoie les bonnes infos à la deuxième, mais sur celle-ci la requête m'affiche des doublons que j'aimerais éviter !
Pièce jointe 248315
J'ai regardé sur le forum et dans plusieurs tutos, il est préconisé d'utiliser DISTINCT, mais si je l'utilise, ma requête est vide,
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
$sql = "SELECT
IDNPlace,
NumPlace,
Reférence,
Personnes.IDPersonne,
Personnes.Nom_Personne,
Personnes.Prenom_Personne,
Personnes.Paiement,
Personnes.Motet,
Instruments.Instrument,
Concert.titreconcert,
Concert.lieu,
DATE_FORMAT ( Concert.dateconcert, '%d/%m/%Y' ) AS datecon,
Zones.Zone,
Prix.Prix
FROM Tab_NumPlace
INNER JOIN Personnes ON Tab_NumPlace.IDPersonne = Personnes.IDPersonne
INNER JOIN Instruments ON Personnes.IDInstruments = Instruments.IDInstruments
INNER JOIN Concert ON Tab_NumPlace.IDconcert = Concert.IDconcert
INNER JOIN Zones ON Tab_NumPlace.IDZone = Zones.IDZone
INNER JOIN Prix ON Zones.IDPrix = Prix.IDPrix
WHERE Tab_NumPlace.IDconcert = '". $idpm ."'
ORDER BY Personnes.Nom_Personne, Personnes.Prenom_Personne ASC"; |
Si dans phpmyadmin je fais :
Code:
1 2
|
SELECT DISTINCT `IDPersonne` FROM `Tab_NumPlace` WHERE `IDconcert` ='1' |
je n'a pas de doublons mais si j'essaie avec les jointures j'ai des messages d'erreur
Voici le message d'erreur de phpmyadmin:
Erreur
Analyse statique :
2 erreurs trouvées lors de l'analyse.
Mot clé non reconnu. (near "DISTINCT" at position 341)
Jeton inattendu. (near "IDPersonne" at position 350)
Requête SQL : Documentation
SELECT IDNPlace, NumPlace, Reférence, Personnes.IDPersonne, Personnes.Nom_Personne, Personnes.Prenom_Personne, Personnes.Paiement, Personnes.Motet, Instruments.Instrument, Concert.titreconcert, Concert.lieu, DATE_FORMAT ( Concert.dateconcert, '%d/%m/%Y' ) AS datecon, Zones.Zone, Prix.Prix DISTINCT IDPersonne FROM Tab_NumPlace INNER JOIN Personnes ON Tab_NumPlace.IDPersonne = Personnes.IDPersonne INNER JOIN Instruments ON Personnes.IDInstruments = Instruments.IDInstruments INNER JOIN Concert ON Tab_NumPlace.IDconcert = Concert.IDconcert INNER JOIN Zones ON Tab_NumPlace.IDZone = Zones.IDZone INNER JOIN Prix ON Zones.IDPrix = Prix.IDPrix WHERE Tab_NumPlace.IDconcert = '1' ORDER BY Personnes.Nom_Personne, Personnes.Prenom_Personne ASC
MySQL a répondu: Documentation
#1064 - Erreur de syntaxe près de 'DISTINCT IDPersonne
FROM Tab_NumPlace
INNER JOIN Personnes ON Tab_NumP' à la ligne 16
Merci d'avance pour votre aide et bon week-end