I have two tables Usuarios
and Logs
.
In the Logs
table I have ID, fecha, hora, usuario, estado, estaciòn
.
In the table Usuarios
I have ID, Empleado, Nombre, Apellido, permisos, ID_Campaña, horario
.
I need to create a statement that queries from the Logs table the fields of fecha, hora , usuario, estado
and that from the Users table I see the nombre, apellido
.
The Logs table contains about 1500 to 2000 records per day, and multiple records of a single user.
I wanted to use a Inner join
, but I do not get the result I want.
Here is my statement:
SELECT 'Date' , 'Time' , 'UserName' as 'Employee' , 'Status'
FROM 'logs'
Inner JOIN (SELECT 'FName' , 'LName' , 'Campaign_ID','Employee' FROM 'users') users
ON 'UserName' = 'Employee'
WHERE 'logs'.'Date' = '1/11/2018'
And 'logs'.'Time' > '07:00:00' And 'logs'.'Time' < '08:00:00'
And 'logs'.'Status' Between 'Clocked In'
AND 'Clocked Out' order by 'logs'.'UserName'
Thanks for your time.