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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Join 2 tables

Author  Topic 

ronnieoverby
Starting Member

36 Posts

Posted - 2008-08-30 : 17:07:05
This is an easy one, I am sure. I have searched, but really I don't know what to search for.

I have an Employees table and a PersistingEmployeeData table.

Both have EmployeeID as primary key.

I want a result set with all records in the Employees table + all the fields in the PersistingEmployeeData table. If there is not a related record in the Persisting table, I just want null values for those fields.

???

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-08-30 : 17:19:28
you want a left join then:

select *
from Employee e
left join PersistingEmployeeData p on e.EmployeeID=p.EmployeeID


elsasoft.org
Go to Top of Page
   

- Advertisement -