pb de doublon avec ma jointure j1.field_name = j2.field_name

pb de doublon avec ma jointure j1.field_name = j2.field_name - SQL/NoSQL - Programmation

Marsh Posté le 07-05-2006 à 10:42:11    

voila, j'ai quelques souci de doublons.  
 
Je vous explique ce que j'ai ces données  
 

SELECT table_name, field_name
FROM liste_jointure
WHERE profile = 'NC'


 

Citation :

table-106-client   field-58-ID_CLIENT
table-56-billing_test  field-58-ID_CLIENT


 
je fais donc cette requete :
 

SELECT j1.table_name, j1.field_name, j2.table_name
FROM liste_jointure j1, liste_jointure j2
WHERE j1.field_name = j2.field_name
AND j1.profile = 'NC'


 
 

Citation :

table-106-client   field-58-ID_CLIENT   table-106-client
table-56-billing_test  field-58-ID_CLIENT  table-106-client
table-106-client  field-58-ID_CLIENT  table-56-billing_test
table-56-billing_test  field-58-ID_CLIENT  table-56-billing_test


 
 
pour eviter les doublons, je rajoute une contrainte dans ma clause Where : j1.table_name != j2.table_name
 

SELECT j1.table_name, j1.field_name, j2.table_name
FROM liste_jointure j1, liste_jointure j2
WHERE j1.field_name = j2.field_name
AND j1.table_name != j2.table_name
AND j1.profile = 'NC'


 
 
 

Citation :

table-56-billing_test   field-58-ID_CLIENT   table-106-client
table-106-client  field-58-ID_CLIENT  table-56-billing_test


 
m'ai ce n'est pas encore ca. J'ai encore des doublons. Je ne sais pas du tout comment faire.
 

Reply

Marsh Posté le 07-05-2006 à 10:42:11   

Reply

Marsh Posté le 07-05-2006 à 11:35:43    

bon vous voulez pas m'aider apparrement  [:alarmclock118]  
 
 
mais j'ai enfin trouvé la solution  :kaola: , il faut utiliser les opérateur <
 

Code :
  1. SELECT j1.table_name, j1.field_name, j2.table_name
  2. FROM liste_jointure j1, liste_jointure j2
  3. WHERE j1.field_name = j2.field_name
  4. AND j1.table_name < j2.table_name
  5. AND j1.profile = 'NC'
  6. LIMIT 0 , 30

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed