Posted by David Portas on 10/29/07 07:16
<pbassutti@hotmail.com> wrote in message
news:1193640256.388620.257210@i13g2000prf.googlegroups.com...
> Hello,
>
> I'm trying to link two tables... one for Employees and the other for
> Timecards
>
> I need to get a list of employees that do not have timecards on an
> SPECIFIC DATE
>
> I tried the follonwing
>
> SELECT Employess.EmployeeID
> FROM Employees LEFT OUTER JOIN Timecards on Employees.EmployeeID =
> Timecards.lmpEmployeeID
> WHERE lmpEmployeeID is NULL and lmpTimecardDate = '10/24/2007'
>
> But it doesn't work. However, when I comment the date condition out
> (lmpTimecardDate = '10/24/2007') it works all right but It's not what
> I need
>
> Another interesting point... if I use the following query... it works
> all right
>
> SELECT Employess.EmployeeID
> FROM Employees
> WHERE Employees.EmployeeID not in (select Timecards.EmployeeID from
> Timecards
> where TimecardDate = '10/24/2007')
>
> I'd like to be able to use the Left Outer Join option.... Am I doing
> something wrong?... or is it that if It doesn't like the condition I'm
> usgin in the WHERE clause (TimecardDate = '10/24/2007')
>
> Thanks for your help
>
> Pablo
>
Put any outer (non-preserved) table references into the ON clause:
SELECT Employess.EmployeeID
FROM Employees
LEFT OUTER JOIN Timecards
ON Employees.EmployeeID = Timecards.lmpEmployeeID
AND lmpTimecardDate = '20071024'
WHERE lmpEmployeeID is NULL ;
--
David Portas
Navigation:
[Reply to this message]
|