SQL Query to Join Two Tables Based Off Closest Timestamp

后端 未结 3 1947
眼角桃花
眼角桃花 2020-12-16 12:41

I have two tables in SQL and I need to be able to do a join based off of the timestamp in table B that is earlier than or equal to the timestamp in table A.

So, here

3条回答
  •  情歌与酒
    2020-12-16 13:23

    change the time stamp and use an int as a key to connect the tables. this will work much faster then comparing date

    table 1 field1 field2 field3 ConnectorField

    table2 field1 field2 field3 ConnectorField

    and all you need to do is select * from table1 T1 inner join table2 T2 on T1.ConnectorField = T2.ConnectorField

提交回复
热议问题