How to get records (Time.Checked) Not used in another table in different fields (Time Input.Assistance or Time Out.Assistance)?

0

In an Assistance System I have the tables:

Checks:

  • IDEmployed
  • HoraChecada
  • DateChecked

At the time of processing the check it generates me an Assistance only using TimeChecada I do not know the idChecada used for the table:

Support:

  • IDEmployed
  • Date of Assistance
  • Time_Entry
  • Time_Exit

How to get the unused checks (time) in the attendance table (can it be used for Entry Time or Time of Departure)? I did the Next Query but I keep adding the checks used:

SELECT a2.ID_Empleado AS IDEmpleado, a2.Fecha AS FechaChecada,
a2.Hora_Checada, b2.Hora_Entrada, b2.Hora_Salida, b2.Fecha AS FechaAsistencia
FROM
(SELECT
        *
    FROM
        checadas AS a
    WHERE
        a.Fecha >= '2018-05-6'
    AND a.Fecha <= '2018-05-07' ) AS a2
left JOIN (
SELECT *
    FROM
        'asistencia' AS a
    WHERE
        (
            a.Fecha >= '2018-05-6'
            AND a.Fecha <= '2018-05-07'
        )
    AND (
        (
            a.Hora_Entrada IS NULL OR a.Hora_Entrada = '0000-00-00'
        ) OR (
            a.Hora_Salida IS NULL OR a.Hora_Salida = '0000-00-00'
        )
    )
) AS b2 on b2.ID_Empleado = a2.ID_Empleado 
  AND b2.Fecha  = a2.Fecha  
  AND(
       (a2.Hora_Checada <> b2.Hora_Entrada or b2.Hora_Entrada is NULL)  
        and (a2.Hora_Checada <> b2.Hora_Salida  or b2.Hora_Salida is NULL)) 
 ORDER BY
 IDEmpleado ASC

    
asked by byok22 08.05.2018 в 17:33
source

0 answers