Jump to content

Combining two tables on join on Datetime


Recommended Posts

Hi, i have a problem with my sql query, I tried everything but until now not the right results.
Problem :
I have two tables, One  that is called Alarms and the other one Logs.
From Alarms I want to use the fields Machine, Message en datetime which is in 2020-02-27 19:11:54:123 format.  In the table Logs I have the fields Anode and Datetime also in 2020-02-27 19:11:54:123  format.
When a alarms occurs I want to use the datetime field to look for the Anode in the other table Logs with the same Datetime value but only on the whole second, I want only one value back.
So the ouput would be someting like 
Machine, Message ,Datetime,Anode 
I believe I have to use the LEFT JOIN instruction :
SELECT Machine,Message,DateTime,Anode
FROM Table1.Alarms
ON table1.DateTime = table2.DateTime;  
Can Anyone help me with this ?
Thanks in advance, Peter


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...