Sunday 15 April 2012

sql - Left Excluding join not working -


I have a table that checks the tracks when an employee wanders in and out of a factory. There is a similar table that tracks a worker's roster; I need to know that when a worker is standing without any roster, that means they work when they were not rostarded.

Example table data:

Clocks: Date Date Start Time Expiry 2013/06/25 09:00 17: 00 Smith 2013-06-26 09:03 17:01 Smith 2013/06/27 08:58 16:57 Brown 2013/06/25 09:00 17:00

Roster: Date Date StartTime EndTime Smith 2013/06/25 09:00 17:00 Smith 2013/06/27 09:00 17:00

So give me Smith / 2013/06/26 and Brown as of 2013/06/25 There was no roster for the worker in one day because they used to work.

My script is not working below - I just get blank returns. Any ideas why? Select

  to leave except the C clock and clocks.date = roster.date on the Roster R1 and enter the left r2 on c.name = r2. Name Where r1.date IS NULL  
   

SELECT c.name, c.date FROM clocks C LEFT JOIN ROSTER r ON c.date = r.date and c.name = r.name WHERE r.date IS NULL

This query returns all names / dates from the table of clocks Where there is no equal line in the roster table, joining only 1 (Talking to join the 2 part) is necessary.

No comments:

Post a Comment