PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > inner join on 3 tables produces duplicates
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
inner join on 3 tables produces duplicates

Réponse
 
LinkBack Outils de la discussion
Vieux 19/05/2008, 15h08   #1
Whiskey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut inner join on 3 tables produces duplicates

table 1
abc
241060 3332.29


table 2
abc def
241060 OH_Adm_InsPremOth


table 3
def
OH_Adm_InsPremOth 3332.29


result of inner join table 1 abc = table 2 abc
and
inner join table 2 def = table 3 def

241060 3332.29 OH_Adm_InsPremOth 3332.29

The above is fine but if I have


table 1
abc
241060 3332.29
241070 5000.00


table 2
abc def
241060 OH_Adm_InsPremOth
241070 OH_Adm_InsPremOth


table 3
def
OH_Adm_InsPremOth 8332.29

result of inner join table 1 abc = table 2 abc
and

inner join table 2 def = table 3 def

241060 3332.29 OH_Adm_InsPremOth 8332.29
241060 3332.29 OH_Adm_InsPremOth 8332.29
241070 5000 OH_Adm_InsPremOth 8332.29
241070 5000 OH_Adm_InsPremOth 8332.29


  Réponse avec citation
Vieux 20/05/2008, 01h40   #2
Eric Isaacs
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: inner join on 3 tables produces duplicates

If you add SELECT DISTINCT ... that would only give you 2 back, but
the join probably isn't correct. Can you send us some actual SQL. If
you do your join right, you should only get 2 results back from the
second scenario without the SELECT DISTINCT.

  Réponse avec citation
Vieux 20/05/2008, 11h11   #3
Whiskey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: inner join on 3 tables produces duplicates

Hi, This is my SQL

SELECT q.account, q.entity, q.time_period, q.value1, ltrim(h.account),
h.value1 , h.ent, h.icp, h.c1, h.c2, h.c3, h.c4, ma.reverse
FROM q2 q
INNER JOIN maps ma ON q.account = ma.srcacc
INNER JOIN hfm h ON ltrim(ma.dstacc) = ltrim(h.account)
where q.entity = '2111'
and q.time_period = '03'

Regards


"Eric Isaacs" wrote:

> If you add SELECT DISTINCT ... that would only give you 2 back, but
> the join probably isn't correct. Can you send us some actual SQL. If
> you do your join right, you should only get 2 results back from the
> second scenario without the SELECT DISTINCT.
>
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h29.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11325 seconds with 11 queries