Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:

Hi,

I have two tables (table1 and table2):

Table1:
fld_1 (PK)
fld_2
fld_3 

Table2:
fld_a (PK)
fld_b
fld_c

Table1.fld_1 and Table2.fld_b are related.

What I want is a list which selects unique rows in Table1 which related to Table2.

So:

Table1:
1   Jim      Jones
2   Geoff   Hill
3   Tony   James

Table2:
1   1   Bob
2   1   Milly
3   1   Tilly
4   2   Joe
5   2   Jilly
6   3   Frank

So Jim should related to: Bob, Milly and Tilly. Geoff: Joe and Jilly. And Tony: Frank.

An inner join returns multiple records of Jim and Geof as there are multiple records relating to them, where as I only want them to appear once.

Any suggestions? :( 

Posted

DISTINCT is the keyword you want, I believe.

 
Share this answer
 
But I also need it to show Jim and Jones... distinct will only display one field...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900