Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One to Many Join should return only 1 corr. record
Message
De
20/08/1999 08:08:42
 
 
À
Tous
Information générale
Forum:
Visual C++
Catégorie:
Autre
Titre:
One to Many Join should return only 1 corr. record
Divers
Thread ID:
00255776
Message ID:
00255776
Vues:
37
I have two tables A and B where A contains field1 and field2 and table B contains field3 and field4. What I want is to get the corresponding value of field4 from table B. I tried:

select distinct A.field1, B.field4 from A, B where A.field1 = A.field3

But since A.field1 has many occurences in B.field3 the result set returns records I do not want. And so it's slow. It appears like this:

field1 field4
0001 abc
0001 abc
0002 cde
0002 cde
0002 cde

If i change the sql statement to:

select distinct A.field1, B.field4, B.field5 from A, B where A.field1 = A.field3

I get:

field1 field4 field5
0001 abc 01
0001 abc 02
0002 cde 11
0002 cde 12
0002 cde 13

How can I construct a query that would return:

field1 field4
0001 abc
0002 cde

Again, thanks for the info :)

Ramon
Répondre
Fil
Voir

Click here to load this message in the networking platform