Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outer join returning more rows than in the table!

Status
Not open for further replies.

Nithindev

Programmer
Joined
Oct 20, 2008
Messages
4
The two queries are returning two different no of rows.Outer join is not supposed to duplicate the rows in the first table right?How do I correct this.


select * from clientcode order by cc_clientcode
result:(5627 row(s) affected)

select cc.cc_clientcode,cc.cc_rmcode,cc.cc_panno,cc.cc_productname
,c.Client_panno,c.client_userid
from clientcode cc LEFT outer join client c
on cc.cc_panno=c.client_panno order by cc_clientcode
Result:(5638 row(s) affected)
 
In the fact it is :-)

The join return ALL records from the clientcode table and ALL matching records from client.
So if you have two or more records in client code that match the JOIN condition you will get two or more records more in the resultset.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Thanks all, the problem was client table had multiple rows with with same client_panno that's a logical error.We are not supposed to have it that way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top