Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
xrum
Yak Posting Veteran
87 Posts |
Posted - 2011-01-05 : 15:12:28
|
| Hi,my first table has about 18K recordsso when iselect * from table2 i get about 18ki'm trying to do a join on it as follows, but i'm getting like 26K back.. what am i doing wrong? i though it's supposed to return all of the "right" aka table2 records plus show me whatever value matches from the first in a separate column...Select t1.fID , t2.*FROM table1 t1 right join table2 t2 on t1.fName = t2.f |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-01-05 : 15:39:03
|
| Impossible to tell. Getting more rows back usually means that thre's not a one-to-one relationship between your tables -- there's something else you need to join on maybe you need to do aggregate table2 before joiningJimEveryday I learn something that somebody else already knew |
 |
|
|
xrum
Yak Posting Veteran
87 Posts |
Posted - 2011-01-05 : 15:44:20
|
| here is an exmaple of my tables:table 1: fID, fNametable 2: id, f, address, etci need to get all records from table 2, with an fID column, whenever f=fNameis it possible? table 1 has unique fNames, while f may match more then once to fName.... |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2011-01-06 : 03:59:54
|
| Try this:select t1.fid, t1.fnamefrom table1 t1 inner join table2 t2on t1.fname = t2.fid |
 |
|
|
|
|
|