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
LEFT JOIN Logs
ON table1.DateTime = table2.DateTime;  
Can Anyone help me with this ?
Thanks in advance, Peter


 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...