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 |
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-11-22 : 08:53:52
|
| Hi,Two tables are being used.tbl1 with 777 recordstbl2 with 55 recordsI am using a left join on these two tables on the field which is common to both of them.Question:Why do I get 2841c records.I thought I should get 777 records.Am I right?Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-11-22 : 08:57:04
|
not necessary. Depending on your JOIN condition, it might return more than 1 record from the RIGHT table per record in the LEFT table. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-11-22 : 09:10:39
|
| why would it do that? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-11-22 : 09:12:31
|
how the records return does not solely depend on the JOIN type : INNER JOIN or LEFT or RIGHT JOIN. It is also depending on the join condition KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-11-22 : 09:20:17
|
| Join condition is:from #tblAccrual as temp left join Country as c on temp.[Currency code] = c.Ccy |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-11-22 : 09:23:35
|
check you data. Is Ccy unique in table Country ? There might be more than 1 records in Country with the same Ccy KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2011-11-22 : 10:26:54
|
| Yes, you are right.Solved.Thanks |
 |
|
|
|
|
|