Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

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.

Flowing Fount of Yak Knowledge

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

Posting Yak Master

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

Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000