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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Regarding connecting 2 tables

Author  Topic 

sunrag77
Starting Member

8 Posts

Posted - 2009-07-29 : 07:05:59
Hi

I have two tables oinv and orct. key relationship field is oinv.receiptnum = orct.docnum.

In oinv there 5000 records. On that 5000, for only 2000 records receiptnum is there, balance 3000 there is no receipt num. I want to get the receipt date for that 2000 records in oinv records from orct.

if i run the below query, its showing only the 2000 records which are having receipt number, balance 3000 records its not showing. How to get all the 5000 records with receipt date for the records having receiptnum.

select oinv.docdate, oinv.docnum, oinv.receiptnum, orct.docdate
from oinv inner join orct on oinv.receiptnum = orct.docnum

pl help on this.

Regards
Sundaram

Mangal Pardeshi
Posting Yak Master

110 Posts

Posted - 2009-07-29 : 07:08:44
Sundaram,
Try a LEFT JOIN instead of INNER JOIN
http://msdn.microsoft.com/en-us/library/ms187518.aspx

Mangal Pardeshi
http://mangalpardeshi.blogspot.com
Go to Top of Page
   

- Advertisement -