SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Having trouble with a join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Munchausen
Starting Member

25 Posts

Posted - 10/18/2005 :  11:40:05  Show Profile  Reply with Quote
I'm having a problem with a join.

Table1 has a record number column, and so does Table2. Not every record number in Table1 exists in Table2, but many do.

I'm trying to display all of the records in Table1, with some columns from Table2.

I've tried:

select t1.recordno, t2.columname
from Table1 t1 left outer join Table2 t2
on t1.recordno = t2.recordno

Unfortunately, this is only returning rows for records that exist in Table 1 and Table2 (t2.columname is never null), but I want it to display all records from Table1, even if they don't have a corresponding record number in Table2.

Any help would be greatly appreciated.

blindman
Flowing Fount of Yak Knowledge

USA
2365 Posts

Posted - 10/18/2005 :  12:03:30  Show Profile  Reply with Quote
Your query is correctly formatted to display all records from Table1, along with any corresponding records from Table2. So something else fishy is going on...
Go to Top of Page

r937
Posting Yak Master

Canada
112 Posts

Posted - 10/18/2005 :  12:05:10  Show Profile  Visit r937's Homepage  Reply with Quote
i bet you also have a WHERE condition on some column in table 2

move this condition to the ON clause

rudy
http://r937.com/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000