August 14, 2006 at 8:56 am
I have module log have DOB and Name and employee table DOB and Name. I want to get the result who are in the employee tables but not in the module log . Thanks.
August 14, 2006 at 9:39 am
Be careful with nulls but try something like:
select *
from dbo.Employees E
where not exists (select *
from dbo.ModuleLog L
where L.EmployeeName = E.EmployeeName
and L.DOB = E.DOB)
or
select E.*
from dbo.Employees E
left join dbo.ModuleLog L on E.EmployeeName = L.EmployeeName and E.DOB = L.DOB
where L.EmployeeName is null
August 14, 2006 at 9:57 am
Thanks. It is well done.
August 14, 2006 at 11:05 am
August 14, 2006 at 2:13 pm
August 15, 2006 at 11:04 am
August 15, 2006 at 11:08 am
I did not have SQL server 2005. I used the first method.
select *
from dbo.Employees E
where not exists (select *
from dbo.ModuleLog L
where L.EmployeeName = E.EmployeeName
and L.DOB = E.DOB).
Since I felt no join is better. It is fast. Thanks.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply