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 2000 Forums
 Transact-SQL (2000)
 inner join problem

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2005-02-28 : 09:57:57
Hi,

I need to return a list of employees including their name,city,telephone etc.
I have a table in sql called EmployeeDetails with the following fields:
EmpId,Firstname,Lastname,Tel,Cell, CityID which is smallint.

I also have another table called CITY:
CityId,Cityname

I have a simple query:
Select * from EmployeeDetails
inner join city on city.id=EmployeeDetails.cityid

The problem is that some employees don't have an entry for City in EmployeeDetails and the field is null and therefore, that employee isn't shown in the result set. How can I also show employees who have NULL in the city field?

Thanks

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2005-02-28 : 10:10:08
Nevermind, I used inner join instead of outer join.
Go to Top of Page

swasheck
Starting Member

1 Post

Posted - 2005-03-02 : 11:02:33
Yeah ... a LEFT JOIN would do what you wanted
Go to Top of Page
   

- Advertisement -